@xeokit/xeokit-sdk 2.6.64 → 2.6.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +277 -272
- package/dist/xeokit-sdk.es.js +277 -272
- package/dist/xeokit-sdk.es5.js +132 -119
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/extras/PointerCircle/PointerCircle.js +1 -1
- package/src/extras/PointerLens/PointerLens.js +27 -46
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +29 -20
- package/src/plugins/AnnotationsPlugin/Annotation.js +3 -0
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +27 -33
- package/src/plugins/SectionPlanesPlugin/Control.js +36 -126
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +10 -4
- package/src/plugins/lib/html/MenuEvent.js +3 -1
- package/src/viewer/scene/model/SceneModel.js +1 -0
- package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +1 -2
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +4 -1
- package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +4 -1
- package/src/viewer/scene/sectionPlane/SectionPlane.js +79 -1
- package/src/viewer/scene/webgl/Renderer.js +9 -3
- package/types/extras/PointerCircle/PointerCircle.d.ts +50 -0
- package/types/extras/PointerCircle/index.d.ts +1 -0
- package/types/plugins/AngleMeasurementsPlugin/index.d.ts +2 -1
- package/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts +4 -0
- package/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts +121 -0
- package/types/plugins/DotBIMLoaderPlugin/index.d.ts +1 -0
- package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +4 -0
- package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +4 -0
- package/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts +4 -0
- package/types/plugins/TreeViewPlugin/TreeViewPlugin.d.ts +4 -0
- package/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +4 -0
- package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +19 -1
- package/types/plugins/index.d.ts +2 -0
- package/types/plugins/lib/ui/index.d.ts +12 -0
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _DEFAULT_SAMPLER;var _marked=/*#__PURE__*/_regeneratorRuntime().mark(makeStringIterator),_marked2=/*#__PURE__*/_regeneratorRuntime().mark(makeArrayBufferIterator),_marked3=/*#__PURE__*/_regeneratorRuntime().mark(makeMeshPrimitiveIterator);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){_defineProperty2(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 _defineProperty2(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 _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 _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 _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 _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(_e13){throw _e13;},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(_e14){didErr=true;err=_e14;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}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 _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 _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;}/**
|
|
1
|
+
var _DEFAULT_SAMPLER;var _marked=/*#__PURE__*/_regeneratorRuntime().mark(makeStringIterator),_marked2=/*#__PURE__*/_regeneratorRuntime().mark(makeArrayBufferIterator),_marked3=/*#__PURE__*/_regeneratorRuntime().mark(makeMeshPrimitiveIterator);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){_defineProperty2(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 _defineProperty2(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 _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 _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(_e13){throw _e13;},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(_e14){didErr=true;err=_e14;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}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;}/**
|
|
2
2
|
* Usage:
|
|
3
3
|
*
|
|
4
4
|
* id = myMap.addItem("foo") // ID internally generated
|
|
@@ -387,9 +387,9 @@ menuElement.style.display='block';var menuHeight=menuElement.offsetHeight;var me
|
|
|
387
387
|
* @param viewer The Viewer
|
|
388
388
|
* @param [cfg] PointerLens configuration.
|
|
389
389
|
* @param [cfg.active=true] Whether PointerLens is active. The PointerLens can only be shown when this is `true` (default).
|
|
390
|
-
*/function PointerLens(viewer){var _this6=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerLens);this.viewer=viewer;this.scene=this.viewer.scene;this._lensCursorDiv=document.createElement('div');this.
|
|
391
|
-
this._lensContainer.style.borderRadius="50%";this._lensContainer.style.width="
|
|
392
|
-
this._lensCanvas.style.borderRadius="50%";this._lensCanvas.style.width="
|
|
390
|
+
*/function PointerLens(viewer){var _this6=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerLens);this.viewer=viewer;this.scene=this.viewer.scene;this._lensCursorDiv=document.createElement('div');this._lensParams={canvasSize:300,cursorBorder:2,cursorSize:10};this._lensCursorDiv.style.borderRadius="50%";this._lensCursorDiv.style.width=this._lensParams.cursorSize+"px";this._lensCursorDiv.style.height=this._lensParams.cursorSize+"px";this._lensCursorDiv.style.zIndex="100000";this._lensCursorDiv.style.position="absolute";this._lensCursorDiv.style.pointerEvents="none";this._lensContainer=document.createElement('div');this._lensContainerId=cfg.containerId||'xeokit-lens';this._lensContainer.setAttribute("id",this._lensContainerId);this._lensContainer.style.border="1px solid black";this._lensContainer.style.background="white";// this._lensContainer.style.opacity = "0";
|
|
391
|
+
this._lensContainer.style.borderRadius="50%";this._lensContainer.style.width=this._lensParams.canvasSize+"px";this._lensContainer.style.height=this._lensParams.canvasSize+"px";this._lensContainer.style.zIndex="15000";this._lensContainer.style.position="absolute";this._lensContainer.style.pointerEvents="none";this._lensContainer.style.visibility="hidden";this._lensCanvas=document.createElement('canvas');this._lensCanvas.id="".concat(this._lensContainerId,"-canvas");// this._lensCanvas.style.background = "darkblue";
|
|
392
|
+
this._lensCanvas.style.borderRadius="50%";this._lensCanvas.style.width=this._lensParams.canvasSize+"px";this._lensCanvas.style.height=this._lensParams.canvasSize+"px";this._lensCanvas.style.zIndex="15000";this._lensCanvas.style.pointerEvents="none";document.body.appendChild(this._lensContainer);this._lensContainer.appendChild(this._lensCanvas);this._lensContainer.appendChild(this._lensCursorDiv);this._lensCanvasContext=this._lensCanvas.getContext('2d');this._canvasElement=this.viewer.scene.canvas.canvas;this._canvasPos=null;this._snappedCanvasPos=null;this._lensPosToggle=cfg.lensPosToggle||true;this._lensPosToggleAmount=cfg.lensPosToggleAmount||85;this._lensPosMarginLeft=cfg.lensPosMarginLeft||85;this._lensPosMarginTop=cfg.lensPosMarginTop||25;this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px");this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px");this._zoomLevel=cfg.zoomLevel||2;this._active=cfg.active!==false;this._visible=false;this.snapped=false;this._onViewerRendering=this.viewer.scene.on("rendering",function(){if(_this6._active&&_this6._visible){_this6.update();}});}/**
|
|
393
393
|
* Updates this PointerLens.
|
|
394
394
|
*/_createClass(PointerLens,[{key:"update",value:function update(){if(!this._active||!this._visible){return;}if(!this._canvasPos){return;}var lensRect=this._lensContainer.getBoundingClientRect();var canvasRect=this._canvasElement.getBoundingClientRect();var pointerOnLens=this._canvasPos[0]<lensRect.right&&this._canvasPos[0]>lensRect.left&&this._canvasPos[1]<lensRect.bottom&&this._canvasPos[1]>lensRect.top;this._lensContainer.style.marginLeft="".concat(this._lensPosMarginLeft,"px");if(pointerOnLens){if(this._lensPosToggle){this._lensContainer.style.marginTop="".concat(canvasRect.bottom-canvasRect.top-this._lensCanvas.height-this._lensPosToggleAmount,"px");}else{this._lensContainer.style.marginTop="".concat(this._lensPosMarginTop,"px");}this._lensPosToggle=!this._lensPosToggle;}this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);var size=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,// source canvas
|
|
395
395
|
this._canvasPos[0]-size/2,// source x (zoom center)
|
|
@@ -400,7 +400,7 @@ size,// source height
|
|
|
400
400
|
0,// destination y
|
|
401
401
|
this._lensCanvas.width,// destination width
|
|
402
402
|
this._lensCanvas.height// destination height
|
|
403
|
-
);var
|
|
403
|
+
);var middle=this._lensParams.canvasSize/2-this._lensParams.cursorSize/2-this._lensParams.cursorBorder;var deltaX=this._snappedCanvasPos?this._snappedCanvasPos[0]-this._canvasPos[0]:0;var deltaY=this._snappedCanvasPos?this._snappedCanvasPos[1]-this._canvasPos[1]:0;this._lensCursorDiv.style.left="".concat(middle+deltaX*this._zoomLevel,"px");this._lensCursorDiv.style.top="".concat(middle+deltaY*this._zoomLevel,"px");}/**
|
|
404
404
|
* Sets the zoom factor for the lens.
|
|
405
405
|
*
|
|
406
406
|
* This is `2` by default.
|
|
@@ -434,10 +434,10 @@ this._lensCanvas.height// destination height
|
|
|
434
434
|
* This is called by plugins.
|
|
435
435
|
* @returns {Boolean}
|
|
436
436
|
* @private
|
|
437
|
-
*/function get(){return this._snapped;}/**
|
|
437
|
+
*/function get(){return this._snapped;},set:function set(snapped){this._snapped=snapped;var _ref4=snapped?["greenyellow","green"]:["pink","red"],_ref5=_slicedToArray(_ref4,2),bg=_ref5[0],border=_ref5[1];this._lensCursorDiv.style.background=bg;this._lensCursorDiv.style.border=this._lensParams.cursorBorder+"px solid "+border;}},{key:"_updateActiveVisible",value:function _updateActiveVisible(){this._lensContainer.style.visibility=this._active&&this._visible?"visible":"hidden";this.update();}/**
|
|
438
438
|
* Sets if this PointerLens is active.
|
|
439
439
|
* @param active
|
|
440
|
-
|
|
440
|
+
*/},{key:"active",get:/**
|
|
441
441
|
* Gets if this PointerLens is active.
|
|
442
442
|
* @returns {Boolean}
|
|
443
443
|
*/function get(){return this._active;}/**
|
|
@@ -445,15 +445,15 @@ this._lensCanvas.height// destination height
|
|
|
445
445
|
* This is set by plugins.
|
|
446
446
|
* @param visible
|
|
447
447
|
* @private
|
|
448
|
-
*/,set:function set(active){this._active=active;this.
|
|
448
|
+
*/,set:function set(active){this._active=active;this._updateActiveVisible();}},{key:"visible",get:/**
|
|
449
449
|
* Gets if this PointerLens is visible.
|
|
450
450
|
* This is called by plugins.
|
|
451
451
|
* @returns {Boolean}
|
|
452
452
|
* @private
|
|
453
453
|
*/function get(){return this._visible;}/**
|
|
454
454
|
* Destroys this PointerLens.
|
|
455
|
-
*/,set:function set(visible){this._visible=visible;this.
|
|
456
|
-
var doublePrecision=true;var FloatArrayType=doublePrecision?Float64Array:Float32Array;var tempVec3a$
|
|
455
|
+
*/,set:function set(visible){this._visible=visible;this._updateActiveVisible();}},{key:"destroy",value:function destroy(){if(!this._destroyed){this.viewer.scene.off(this._onViewerRendering);this._lensContainer.removeChild(this._lensCanvas);document.body.removeChild(this._lensContainer);this._destroyed=true;}}}]);return PointerLens;}();// Some temporary vars to help avoid garbage collection
|
|
456
|
+
var doublePrecision=true;var FloatArrayType=doublePrecision?Float64Array:Float32Array;var tempVec3a$O=new FloatArrayType(3);var tempMat1=new FloatArrayType(16);var tempMat2=new FloatArrayType(16);var tempVec4$2=new FloatArrayType(4);/**
|
|
457
457
|
* @private
|
|
458
458
|
*/var math={setDoublePrecisionEnabled:function setDoublePrecisionEnabled(enable){doublePrecision=enable;FloatArrayType=doublePrecision?Float64Array:Float32Array;},getDoublePrecisionEnabled:function getDoublePrecisionEnabled(){return doublePrecision;},MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,MAX_INT:10000000,/**
|
|
459
459
|
* The number of radiians in a degree (0.0174532925).
|
|
@@ -1457,7 +1457,7 @@ if(edge.face2!==undefined){normal1=faces[edge.face1].normal;normal2=faces[edge.f
|
|
|
1457
1457
|
* @param {number} positions Flat array of 3D positions.
|
|
1458
1458
|
* @param {number} numElementsPerPosition Number of elements perposition - usually either 3 or 4.
|
|
1459
1459
|
* @returns {boolean}
|
|
1460
|
-
*/math.planeClipsPositions3=function(pos,dir,positions){var numElementsPerPosition=arguments.length>3&&arguments[3]!==undefined?arguments[3]:3;for(var _i26=0,len=positions.length;_i26<len;_i26+=numElementsPerPosition){tempVec3a$
|
|
1460
|
+
*/math.planeClipsPositions3=function(pos,dir,positions){var numElementsPerPosition=arguments.length>3&&arguments[3]!==undefined?arguments[3]:3;for(var _i26=0,len=positions.length;_i26<len;_i26+=numElementsPerPosition){tempVec3a$O[0]=positions[_i26+0]-pos[0];tempVec3a$O[1]=positions[_i26+1]-pos[1];tempVec3a$O[2]=positions[_i26+2]-pos[2];var dotProduct=tempVec3a$O[0]*dir[0]+tempVec3a$O[1]*dir[1]+tempVec3a$O[2]*dir[2];if(dotProduct<0){return true;}}return false;};var MAX_KD_TREE_DEPTH$1=15;// Increase if greater precision needed
|
|
1461
1461
|
var kdTreeDimLength$1=new Float32Array(3);/**
|
|
1462
1462
|
* Automatically indexes a {@link Viewer}'s {@link Entity}s in a 3D k-d tree
|
|
1463
1463
|
* to support fast collision detection with 3D World-space axis-aligned boundaries (AABBs) and frustums.
|
|
@@ -1979,11 +1979,11 @@ return component;}},{key:"_checkComponent",value:function _checkComponent(expect
|
|
|
1979
1979
|
*/this.fire("destroyed",this.destroyed=true);// Must fire before we blow away subscription maps, below
|
|
1980
1980
|
// Unsubscribe from child components and destroy then
|
|
1981
1981
|
var id;var attachment;var component;var subs;var i;var len;if(this._attachments){for(id in this._attachments){if(this._attachments.hasOwnProperty(id)){attachment=this._attachments[id];component=attachment.component;subs=attachment.subs;for(i=0,len=subs.length;i<len;i++){component.off(subs[i]);}if(attachment.managingLifecycle){component.destroy();}}}}if(this._ownedComponents){for(id in this._ownedComponents){if(this._ownedComponents.hasOwnProperty(id)){component=this._ownedComponents[id];component.destroy();delete this._ownedComponents[id];}}}this.scene._removeComponent(this);// Memory leak avoidance
|
|
1982
|
-
this._attached={};this._attachments=null;this._subIdMap=null;this._subIdEvents=null;this._eventSubs=null;this._events=null;this._eventCallDepth=0;this._ownedComponents=null;this._updateScheduled=false;}}]);return Component;}();var tempVec3a$
|
|
1982
|
+
this._attached={};this._attachments=null;this._subIdMap=null;this._subIdEvents=null;this._eventSubs=null;this._events=null;this._eventCallDepth=0;this._ownedComponents=null;this._updateScheduled=false;}}]);return Component;}();var tempVec3a$N=math.vec3();var tempVec3b$B=math.vec3();var tempMat4a$s=math.mat4();/**
|
|
1983
1983
|
* @private
|
|
1984
1984
|
*/var FrustumPlane=/*#__PURE__*/function(){function FrustumPlane(){_classCallCheck(this,FrustumPlane);this.normal=math.vec3();this.offset=0;this.testVertex=math.vec3();}_createClass(FrustumPlane,[{key:"set",value:function set(nx,ny,nz,offset){var s=1.0/Math.sqrt(nx*nx+ny*ny+nz*nz);this.normal[0]=nx*s;this.normal[1]=ny*s;this.normal[2]=nz*s;this.offset=offset*s;this.testVertex[0]=this.normal[0]>=0.0?1:0;this.testVertex[1]=this.normal[1]>=0.0?1:0;this.testVertex[2]=this.normal[2]>=0.0?1:0;}}]);return FrustumPlane;}();/**
|
|
1985
1985
|
* @private
|
|
1986
|
-
*/var Frustum$1=/*#__PURE__*/_createClass(function Frustum$1(){_classCallCheck(this,Frustum$1);this.planes=[new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane()];});Frustum$1.INSIDE=0;Frustum$1.INTERSECT=1;Frustum$1.OUTSIDE=2;/** @private */function setFrustum(frustum,viewMat,projMat){var m=math.mulMat4(projMat,viewMat,tempMat4a$s);var m0=m[0];var m1=m[1];var m2=m[2];var m3=m[3];var m4=m[4];var m5=m[5];var m6=m[6];var m7=m[7];var m8=m[8];var m9=m[9];var m10=m[10];var m11=m[11];var m12=m[12];var m13=m[13];var m14=m[14];var m15=m[15];frustum.planes[0].set(m3-m0,m7-m4,m11-m8,m15-m12);frustum.planes[1].set(m3+m0,m7+m4,m11+m8,m15+m12);frustum.planes[2].set(m3-m1,m7-m5,m11-m9,m15-m13);frustum.planes[3].set(m3+m1,m7+m5,m11+m9,m15+m13);frustum.planes[4].set(m3-m2,m7-m6,m11-m10,m15-m14);frustum.planes[5].set(m3+m2,m7+m6,m11+m10,m15+m14);}/** @private */function frustumIntersectsAABB3(frustum,aabb){var ret=Frustum$1.INSIDE;var min=tempVec3a$
|
|
1986
|
+
*/var Frustum$1=/*#__PURE__*/_createClass(function Frustum$1(){_classCallCheck(this,Frustum$1);this.planes=[new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane()];});Frustum$1.INSIDE=0;Frustum$1.INTERSECT=1;Frustum$1.OUTSIDE=2;/** @private */function setFrustum(frustum,viewMat,projMat){var m=math.mulMat4(projMat,viewMat,tempMat4a$s);var m0=m[0];var m1=m[1];var m2=m[2];var m3=m[3];var m4=m[4];var m5=m[5];var m6=m[6];var m7=m[7];var m8=m[8];var m9=m[9];var m10=m[10];var m11=m[11];var m12=m[12];var m13=m[13];var m14=m[14];var m15=m[15];frustum.planes[0].set(m3-m0,m7-m4,m11-m8,m15-m12);frustum.planes[1].set(m3+m0,m7+m4,m11+m8,m15+m12);frustum.planes[2].set(m3-m1,m7-m5,m11-m9,m15-m13);frustum.planes[3].set(m3+m1,m7+m5,m11+m9,m15+m13);frustum.planes[4].set(m3-m2,m7-m6,m11-m10,m15-m14);frustum.planes[5].set(m3+m2,m7+m6,m11+m10,m15+m14);}/** @private */function frustumIntersectsAABB3(frustum,aabb){var ret=Frustum$1.INSIDE;var min=tempVec3a$N;var max=tempVec3b$B;min[0]=aabb[0];min[1]=aabb[1];min[2]=aabb[2];max[0]=aabb[3];max[1]=aabb[4];max[2]=aabb[5];var bminmax=[min,max];for(var _i27=0;_i27<6;++_i27){var plane=frustum.planes[_i27];if(plane.normal[0]*bminmax[plane.testVertex[0]][0]+plane.normal[1]*bminmax[plane.testVertex[1]][1]+plane.normal[2]*bminmax[plane.testVertex[2]][2]+plane.offset<0.0){return Frustum$1.OUTSIDE;}if(plane.normal[0]*bminmax[1-plane.testVertex[0]][0]+plane.normal[1]*bminmax[1-plane.testVertex[1]][1]+plane.normal[2]*bminmax[1-plane.testVertex[2]][2]+plane.offset<0.0){ret=Frustum$1.INTERSECT;}}return ret;}/**
|
|
1987
1987
|
* Picks a {@link Viewer}'s {@link Entity}s with a canvas-space 2D marquee box.
|
|
1988
1988
|
*
|
|
1989
1989
|
* [<img src="https://xeokit.github.io/xeokit-sdk/assets/images/MarqueeSelect.gif">](https://xeokit.github.io/xeokit-sdk/examples/picking/#marqueePick_select)
|
|
@@ -2181,7 +2181,7 @@ return;}if(!isMouseDown){return;}clearTimeout(mouseDownTimer);if(!isMouseDraggin
|
|
|
2181
2181
|
*/function PointerCircle(viewer){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointerCircle);this.viewer=viewer;this.scene=this.viewer.scene;this._circleDiv=document.createElement('div');this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._circleDiv,this.viewer.scene.canvas.canvas);this._circleDiv.style.backgroundColor="transparent";this._circleDiv.style.border="2px solid green";this._circleDiv.style.borderRadius="50px";this._circleDiv.style.width="50px";this._circleDiv.style.height="50px";this._circleDiv.style.margin="-200px -200px";this._circleDiv.style.zIndex="100000";this._circleDiv.style.position="absolute";this._circleDiv.style.pointerEvents="none";this._circlePos=null;this._circleMaxRadius=200;this._circleMinRadius=2;this._active=cfg.active!==false;this._visible=false;this._running=false;this._destroyed=false;}/**
|
|
2182
2182
|
* Show the circle at the given canvas coordinates and begin shrinking it.
|
|
2183
2183
|
*/_createClass(PointerCircle,[{key:"start",value:function start(circlePos){var _this12=this;if(this._destroyed){return;}this._circlePos=circlePos;this._running=false;this._circleRadius=this._circleMaxRadius;this._circleDiv.style.borderRadius="".concat(this._circleRadius,"px");this._circleDiv.style.marginLeft="".concat(this._circlePos[0]-this._circleRadius,"px");this._circleDiv.style.marginTop="".concat(this._circlePos[1]-this._circleRadius,"px");var startValue=this._circleMaxRadius;var endValue=2;var startTime;var duration=300;var animateCircle=function animateCircle(currentTime){if(!_this12._running){return;}if(!startTime){startTime=currentTime;}var elapsedTime=currentTime-startTime;var progress=Math.min(elapsedTime/duration,1);var interpolatedValue=startValue+(endValue-startValue)*progress;_this12._circleRadius=interpolatedValue;_this12._circleDiv.style.width="".concat(_this12._circleRadius,"px");_this12._circleDiv.style.height="".concat(_this12._circleRadius,"px");_this12._circleDiv.style.marginLeft="".concat(_this12._circlePos[0]-_this12._circleRadius/2,"px");_this12._circleDiv.style.marginTop="".concat(_this12._circlePos[1]-_this12._circleRadius/2,"px");if(progress<1){requestAnimationFrame(animateCircle);}};this._running=true;requestAnimationFrame(animateCircle);this._circleDiv.style.visibility="visible";}/**
|
|
2184
|
-
* Stop the
|
|
2184
|
+
* Stop the shrinking circle and hide it.
|
|
2185
2185
|
*/},{key:"stop",value:function stop(){if(this._destroyed){return;}this._running=false;this._circleRadius=this._circleMaxRadius;this._circleDiv.style.borderRadius="".concat(this._circleRadius,"px");this._circleDiv.style.visibility="hidden";}/**
|
|
2186
2186
|
* Sets the zoom factor for the lens.
|
|
2187
2187
|
*
|
|
@@ -2283,10 +2283,11 @@ callback.call(scope||this,value);}return subId;}/**
|
|
|
2283
2283
|
*/},{key:"destroy",value:function destroy(){this.viewer.removePlugin(this);}}]);return Plugin;}();var os={isIphoneSafari:function isIphoneSafari(){var userAgent=window.navigator.userAgent;var isIphone=/iPhone/i.test(userAgent);var isSafari=/Safari/i.test(userAgent)&&!/Chrome/i.test(userAgent);return isIphone&&isSafari;},isTouchDevice:function isTouchDevice(){return'ontouchstart'in window||//works for most devices
|
|
2284
2284
|
navigator.maxTouchPoints>0||//works for modern touch devices
|
|
2285
2285
|
navigator.mxMaxTouchPoints>0//works for older microsoft touch devices
|
|
2286
|
-
;}}
|
|
2286
|
+
;}};//failCallback will be called when the press is not long enough to considered a long press
|
|
2287
|
+
function addContextMenuListener(elem,callback){var failCallback=arguments.length>2&&arguments[2]!==undefined?arguments[2]:function(){};if(!elem||!callback)return;var timeout=null;var longPressTimer=500;var MOVE_THRESHOLD=3;var startX,startY;var touchStartHandler=function touchStartHandler(event){event.preventDefault();if(timeout){clearTimeout(timeout);timeout=null;}// If more than one finger touches the screen, cancel the timeout
|
|
2287
2288
|
if(event.touches.length>1)return;var touch=event.touches[0];startX=touch.clientX;startY=touch.clientY;timeout=setTimeout(function(){event.clientX=touch.clientX;event.clientY=touch.clientY;callback(event);clearTimeout(timeout);timeout=null;},longPressTimer);};var globalTouchStartHandler=function globalTouchStartHandler(event){// Cancel timeout if multiple touches are detected anywhere on the screen
|
|
2288
|
-
if(event.touches.length>1&&timeout){clearTimeout(timeout);timeout=null;}};var touchMoveHandler=function touchMoveHandler(event){if(!timeout)return;var touch=event.touches[0];var deltaX=Math.abs(touch.clientX-startX);var deltaY=Math.abs(touch.clientY-startY);if(deltaX>MOVE_THRESHOLD||deltaY>MOVE_THRESHOLD){clearTimeout(timeout);timeout=null;}};var touchEndHandler=function touchEndHandler(event){event.preventDefault();if(timeout){clearTimeout(timeout);timeout=null;}};var contextMenuHandler=function contextMenuHandler(event){callback(event);event.preventDefault();event.stopPropagation();};if(os.isIphoneSafari()){elem.addEventListener('touchstart',touchStartHandler);elem.addEventListener('touchmove',touchMoveHandler);elem.addEventListener('touchend',touchEndHandler);window.addEventListener('touchstart',globalTouchStartHandler);}else{elem.addEventListener('contextmenu',contextMenuHandler);}return function removeContextMenuListener(){if(os.isIphoneSafari()){elem.removeEventListener('touchstart',touchStartHandler);elem.removeEventListener('touchmove',touchMoveHandler);elem.removeEventListener('touchend',touchEndHandler);window.removeEventListener('touchstart',globalTouchStartHandler);}else{elem.removeEventListener('contextmenu',contextMenuHandler);}};}/** @private */var Dot=/*#__PURE__*/function(){function Dot(parentElement){var _this13=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Dot);this._highlightClass="viewer-ruler-dot-highlighted";this._x=0;this._y=0;this._dot=document.createElement('div');this._dot.className+=this._dot.className?' viewer-ruler-dot':'viewer-ruler-dot';this._dotClickable=document.createElement('div');this._dotClickable.className+=this._dotClickable.className?' viewer-ruler-dot-clickable':'viewer-ruler-dot-clickable';this._visible=cfg.visible!==false;this._culled=false;var dot=this._dot;var dotStyle=dot.style;dotStyle["border-radius"]=25+"px";dotStyle.border="solid 2px white";dotStyle.background="lightgreen";dotStyle.position="absolute";dotStyle["z-index"]=cfg.zIndex===undefined?"40000005":cfg.zIndex;dotStyle.width=8+"px";dotStyle.height=8+"px";dotStyle.visibility=this._visible?"visible":"hidden";dotStyle.top=0+"px";dotStyle.left=0+"px";dotStyle["box-shadow"]="0 2px 5px 0 #182A3D;";dotStyle["opacity"]=1.0;dotStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(dot);var dotClickable=this._dotClickable;var dotClickableStyle=dotClickable.style;dotClickableStyle["border-radius"]=35+"px";dotClickableStyle.border="solid 10px white";dotClickableStyle.position="absolute";dotClickableStyle["z-index"]=cfg.zIndex===undefined?"40000007":cfg.zIndex+1;dotClickableStyle.width=8+"px";dotClickableStyle.height=8+"px";dotClickableStyle.visibility="visible";dotClickableStyle.top=0+"px";dotClickableStyle.left=0+"px";dotClickableStyle["opacity"]=0.0;dotClickableStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(dotClickable);dotClickable.addEventListener('click',function(event){parentElement.dispatchEvent(new MouseEvent('mouseover',event));});if(cfg.onMouseOver){dotClickable.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this13);parentElement.dispatchEvent(new MouseEvent('mouseover',event));});}if(cfg.onMouseLeave){dotClickable.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this13);});}if(cfg.onMouseWheel){dotClickable.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this13);});}if(cfg.onMouseDown){dotClickable.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this13);});}if(cfg.onMouseUp){dotClickable.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this13);});}if(cfg.onMouseMove){dotClickable.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this13);});}if(cfg.onTouchstart){dotClickable.addEventListener('touchstart',function(event){cfg.onTouchstart(event,_this13);});}if(cfg.onTouchmove){dotClickable.addEventListener('touchmove',function(event){cfg.onTouchmove(event,_this13);});}if(cfg.onTouchend){dotClickable.addEventListener('touchend',function(event){cfg.onTouchend(event,_this13);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this13);};addContextMenuListener(dotClickable,contextMenuCallback);}this.setPos(cfg.x||0,cfg.y||0);this.setFillColor(cfg.fillColor);this.setBorderColor(cfg.borderColor);}_createClass(Dot,[{key:"setPos",value:function setPos(x,y){this._x=x;this._y=y;var dotStyle=this._dot.style;dotStyle["left"]=Math.round(x)-6+'px';dotStyle["top"]=Math.round(y)-6+'px';var dotClickableStyle=this._dotClickable.style;dotClickableStyle["left"]=Math.round(x)-14+'px';dotClickableStyle["top"]=Math.round(y)-14+'px';}},{key:"setFillColor",value:function setFillColor(color){this._dot.style.background=color||"lightgreen";}},{key:"setBorderColor",value:function setBorderColor(color){this._dot.style.border="solid 2px"+(color||"black");}},{key:"setOpacity",value:function setOpacity(opacity){this._dot.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._dot.style.visibility=this._dotClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setClickable",value:function setClickable(clickable){this._dotClickable.style["pointer-events"]=clickable?"all":"none";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._dot.classList.add(this._highlightClass);}else{this._dot.classList.remove(this._highlightClass);}}},{key:"destroy",value:function destroy(){this.setVisible(false);if(this._dot.parentElement){this._dot.parentElement.removeChild(this._dot);}if(this._dotClickable.parentElement){this._dotClickable.parentElement.removeChild(this._dotClickable);}}}]);return Dot;}();/** @private */var Label=/*#__PURE__*/function(){function Label(parentElement){var _this14=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Label);this._highlightClass="viewer-ruler-label-highlighted";this._prefix=cfg.prefix||"";this._x=0;this._y=0;this._visible=true;this._culled=false;this._label=document.createElement('div');this._label.className+=this._label.className?' viewer-ruler-label':'viewer-ruler-label';this._timeout=null;var label=this._label;var style=label.style;style["border-radius"]=5+"px";style.color="white";style.padding="4px";style.border="solid 1px";style.background="lightgreen";style.position="absolute";style["z-index"]=cfg.zIndex===undefined?"5000005":cfg.zIndex;style.width="auto";style.height="auto";style.visibility="visible";style.top=0+"px";style.left=0+"px";style["pointer-events"]="all";style["opacity"]=1.0;if(cfg.onContextMenu);label.innerText="";parentElement.appendChild(label);this.setPos(cfg.x||0,cfg.y||0);this.setFillColor(cfg.fillColor);this.setBorderColor(cfg.fillColor);this.setText(cfg.text);if(cfg.onMouseOver){label.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this14);event.preventDefault();});}if(cfg.onMouseLeave){label.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this14);event.preventDefault();});}if(cfg.onMouseWheel){label.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this14);});}if(cfg.onMouseDown){label.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this14);event.stopPropagation();});}if(cfg.onMouseUp){label.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this14);event.stopPropagation();});}if(cfg.onMouseMove){label.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this14);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this14);};addContextMenuListener(label,contextMenuCallback);}}_createClass(Label,[{key:"setPos",value:function setPos(x,y){this._x=x;this._y=y;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosOnWire",value:function setPosOnWire(x1,y1,x2,y2){var x=x1+(x2-x1)*0.5;var y=y1+(y2-y1)*0.5;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosBetweenWires",value:function setPosBetweenWires(x1,y1,x2,y2,x3,y3){var x=(x1+x2+x3)/3;var y=(y1+y2+y3)/3;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setText",value:function setText(text){this._label.innerHTML=this._prefix+(text||"");}},{key:"setFillColor",value:function setFillColor(color){this._fillColor=color||"lightgreen";this._label.style.background=this._fillColor;}},{key:"setBorderColor",value:function setBorderColor(color){this._borderColor=color||"black";this._label.style.border="solid 1px "+this._borderColor;}},{key:"setOpacity",value:function setOpacity(opacity){this._label.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._label.classList.add(this._highlightClass);}else{this._label.classList.remove(this._highlightClass);}}},{key:"setClickable",value:function setClickable(clickable){this._label.style["pointer-events"]=clickable?"all":"none";}},{key:"setPrefix",value:function setPrefix(prefix){if(this._prefix===prefix){return;}this._prefix=prefix;}},{key:"destroy",value:function destroy(){if(this._label.parentElement){this._label.parentElement.removeChild(this._label);}}}]);return Label;}();/** @private */var Wire=/*#__PURE__*/function(){function Wire(parentElement){var _this15=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Wire);this._color=cfg.color||"black";this._highlightClass="viewer-ruler-wire-highlighted";this._wire=document.createElement('div');this._wire.className+=this._wire.className?' viewer-ruler-wire':'viewer-ruler-wire';this._wireClickable=document.createElement('div');this._wireClickable.className+=this._wireClickable.className?' viewer-ruler-wire-clickable':'viewer-ruler-wire-clickable';this._thickness=cfg.thickness||1.0;this._thicknessClickable=cfg.thicknessClickable||6.0;this._visible=true;this._culled=false;var wire=this._wire;var wireStyle=wire.style;wireStyle.border="solid "+this._thickness+"px "+this._color;wireStyle.position="absolute";wireStyle["z-index"]=cfg.zIndex===undefined?"2000001":cfg.zIndex;wireStyle.width=0+"px";wireStyle.height=0+"px";wireStyle.visibility="visible";wireStyle.top=0+"px";wireStyle.left=0+"px";wireStyle['-webkit-transform-origin']="0 0";wireStyle['-moz-transform-origin']="0 0";wireStyle['-ms-transform-origin']="0 0";wireStyle['-o-transform-origin']="0 0";wireStyle['transform-origin']="0 0";wireStyle['-webkit-transform']='rotate(0deg)';wireStyle['-moz-transform']='rotate(0deg)';wireStyle['-ms-transform']='rotate(0deg)';wireStyle['-o-transform']='rotate(0deg)';wireStyle['transform']='rotate(0deg)';wireStyle["opacity"]=1.0;wireStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wire);var wireClickable=this._wireClickable;var wireClickableStyle=wireClickable.style;wireClickableStyle.border="solid "+this._thicknessClickable+"px "+this._color;wireClickableStyle.position="absolute";wireClickableStyle["z-index"]=cfg.zIndex===undefined?"2000002":cfg.zIndex+1;wireClickableStyle.width=0+"px";wireClickableStyle.height=0+"px";wireClickableStyle.visibility="visible";wireClickableStyle.top=0+"px";wireClickableStyle.left=0+"px";// wireClickableStyle["pointer-events"] = "none";
|
|
2289
|
-
wireClickableStyle['-webkit-transform-origin']="0 0";wireClickableStyle['-moz-transform-origin']="0 0";wireClickableStyle['-ms-transform-origin']="0 0";wireClickableStyle['-o-transform-origin']="0 0";wireClickableStyle['transform-origin']="0 0";wireClickableStyle['-webkit-transform']='rotate(0deg)';wireClickableStyle['-moz-transform']='rotate(0deg)';wireClickableStyle['-ms-transform']='rotate(0deg)';wireClickableStyle['-o-transform']='rotate(0deg)';wireClickableStyle['transform']='rotate(0deg)';wireClickableStyle["opacity"]=0.0;wireClickableStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wireClickable);if(cfg.onMouseOver){wireClickable.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this15);});}if(cfg.onMouseLeave){wireClickable.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this15);});}if(cfg.onMouseWheel){wireClickable.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this15);});}if(cfg.onMouseDown){wireClickable.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this15);});}if(cfg.onMouseUp){wireClickable.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this15);});}if(cfg.onMouseMove){wireClickable.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this15);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this15);};addContextMenuListener(wireClickable,contextMenuCallback);}this._x1=0;this._y1=0;this._x2=0;this._y2=0;this._update();}_createClass(Wire,[{key:"visible",get:function get(){return this._wire.style.visibility==="visible";}},{key:"_update",value:function _update(){var length=Math.abs(Math.sqrt((this._x1-this._x2)*(this._x1-this._x2)+(this._y1-this._y2)*(this._y1-this._y2)));var angle=Math.atan2(this._y2-this._y1,this._x2-this._x1)*180.0/Math.PI;var wireStyle=this._wire.style;wireStyle["width"]=Math.round(length)+'px';wireStyle["left"]=Math.round(this._x1)+'px';wireStyle["top"]=Math.round(this._y1)+'px';wireStyle['-webkit-transform']=wireStyle['-moz-transform']=wireStyle['-ms-transform']=wireStyle['-o-transform']=wireStyle['transform']='rotate('+angle+'deg) translate(-'+this._thickness+'px, -'+this._thickness+'px)';var wireClickableStyle=this._wireClickable.style;wireClickableStyle["width"]=Math.round(length)+'px';wireClickableStyle["left"]=Math.round(this._x1)+'px';wireClickableStyle["top"]=Math.round(this._y1)+'px';wireClickableStyle['-webkit-transform']=wireClickableStyle['-moz-transform']=wireClickableStyle['-ms-transform']=wireClickableStyle['-o-transform']=wireClickableStyle['transform']='rotate('+angle+'deg) translate(-'+this._thicknessClickable+'px, -'+this._thicknessClickable+'px)';}},{key:"setStartAndEnd",value:function setStartAndEnd(x1,y1,x2,y2){this._x1=x1;this._y1=y1;this._x2=x2;this._y2=y2;this._update();}},{key:"setColor",value:function setColor(color){this._color=color||"black";this._wire.style.border="solid "+this._thickness+"px "+this._color;}},{key:"setOpacity",value:function setOpacity(opacity){this._wire.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._wire.style.visibility=this._wireClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setClickable",value:function setClickable(clickable){this._wireClickable.style["pointer-events"]=clickable?"all":"none";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._wire.classList.add(this._highlightClass);}else{this._wire.classList.remove(this._highlightClass);}}},{key:"destroy",value:function destroy(visible){if(this._wire.parentElement){this._wire.parentElement.removeChild(this._wire);}if(this._wireClickable.parentElement){this._wireClickable.parentElement.removeChild(this._wireClickable);}}}]);return Wire;}();var tempVec3a$
|
|
2289
|
+
if(event.touches.length>1&&timeout){clearTimeout(timeout);timeout=null;}};var touchMoveHandler=function touchMoveHandler(event){if(!timeout)return;var touch=event.touches[0];var deltaX=Math.abs(touch.clientX-startX);var deltaY=Math.abs(touch.clientY-startY);if(deltaX>MOVE_THRESHOLD||deltaY>MOVE_THRESHOLD){clearTimeout(timeout);timeout=null;}};var touchEndHandler=function touchEndHandler(event){event.preventDefault();if(timeout){failCallback(event);clearTimeout(timeout);timeout=null;}};var contextMenuHandler=function contextMenuHandler(event){callback(event);event.preventDefault();event.stopPropagation();};if(os.isIphoneSafari()){elem.addEventListener('touchstart',touchStartHandler);elem.addEventListener('touchmove',touchMoveHandler);elem.addEventListener('touchend',touchEndHandler);window.addEventListener('touchstart',globalTouchStartHandler);}else{elem.addEventListener('contextmenu',contextMenuHandler);}return function removeContextMenuListener(){if(os.isIphoneSafari()){elem.removeEventListener('touchstart',touchStartHandler);elem.removeEventListener('touchmove',touchMoveHandler);elem.removeEventListener('touchend',touchEndHandler);window.removeEventListener('touchstart',globalTouchStartHandler);}else{elem.removeEventListener('contextmenu',contextMenuHandler);}};}/** @private */var Dot=/*#__PURE__*/function(){function Dot(parentElement){var _this13=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Dot);this._highlightClass="viewer-ruler-dot-highlighted";this._x=0;this._y=0;this._dot=document.createElement('div');this._dot.className+=this._dot.className?' viewer-ruler-dot':'viewer-ruler-dot';this._dotClickable=document.createElement('div');this._dotClickable.className+=this._dotClickable.className?' viewer-ruler-dot-clickable':'viewer-ruler-dot-clickable';this._visible=cfg.visible!==false;this._culled=false;var dot=this._dot;var dotStyle=dot.style;dotStyle["border-radius"]=25+"px";dotStyle.border="solid 2px white";dotStyle.background="lightgreen";dotStyle.position="absolute";dotStyle["z-index"]=cfg.zIndex===undefined?"40000005":cfg.zIndex;dotStyle.width=8+"px";dotStyle.height=8+"px";dotStyle.visibility=this._visible?"visible":"hidden";dotStyle.top=0+"px";dotStyle.left=0+"px";dotStyle["box-shadow"]="0 2px 5px 0 #182A3D;";dotStyle["opacity"]=1.0;dotStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(dot);var dotClickable=this._dotClickable;var dotClickableStyle=dotClickable.style;dotClickableStyle["border-radius"]=35+"px";dotClickableStyle.border="solid 10px white";dotClickableStyle.position="absolute";dotClickableStyle["z-index"]=cfg.zIndex===undefined?"40000007":cfg.zIndex+1;dotClickableStyle.width=8+"px";dotClickableStyle.height=8+"px";dotClickableStyle.visibility="visible";dotClickableStyle.top=0+"px";dotClickableStyle.left=0+"px";dotClickableStyle["opacity"]=0.0;dotClickableStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(dotClickable);dotClickable.addEventListener('click',function(event){parentElement.dispatchEvent(new MouseEvent('mouseover',event));});if(cfg.onMouseOver){dotClickable.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this13);parentElement.dispatchEvent(new MouseEvent('mouseover',event));});}if(cfg.onMouseLeave){dotClickable.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this13);});}if(cfg.onMouseWheel){dotClickable.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this13);});}if(cfg.onMouseDown){dotClickable.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this13);});}if(cfg.onMouseUp){dotClickable.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this13);});}if(cfg.onMouseMove){dotClickable.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this13);});}if(cfg.onTouchstart){dotClickable.addEventListener('touchstart',function(event){cfg.onTouchstart(event,_this13);});}if(cfg.onTouchmove){dotClickable.addEventListener('touchmove',function(event){cfg.onTouchmove(event,_this13);});}if(cfg.onTouchend){dotClickable.addEventListener('touchend',function(event){cfg.onTouchend(event,_this13);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this13);};addContextMenuListener(dotClickable,contextMenuCallback);}this.setPos(cfg.x||0,cfg.y||0);this.setFillColor(cfg.fillColor);this.setBorderColor(cfg.borderColor);}_createClass(Dot,[{key:"setPos",value:function setPos(x,y){this._x=x;this._y=y;var dotStyle=this._dot.style;dotStyle["left"]=Math.round(x)-6+'px';dotStyle["top"]=Math.round(y)-6+'px';var dotClickableStyle=this._dotClickable.style;dotClickableStyle["left"]=Math.round(x)-14+'px';dotClickableStyle["top"]=Math.round(y)-14+'px';}},{key:"setFillColor",value:function setFillColor(color){this._dot.style.background=color||"lightgreen";}},{key:"setBorderColor",value:function setBorderColor(color){this._dot.style.border="solid 2px"+(color||"black");}},{key:"setOpacity",value:function setOpacity(opacity){this._dot.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._dot.style.visibility=this._dotClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setClickable",value:function setClickable(clickable){this._dotClickable.style["pointer-events"]=clickable?"all":"none";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._dot.classList.add(this._highlightClass);}else{this._dot.classList.remove(this._highlightClass);}}},{key:"destroy",value:function destroy(){this.setVisible(false);if(this._dot.parentElement){this._dot.parentElement.removeChild(this._dot);}if(this._dotClickable.parentElement){this._dotClickable.parentElement.removeChild(this._dotClickable);}}}]);return Dot;}();/** @private */var Label=/*#__PURE__*/function(){function Label(parentElement){var _this14=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Label);this._highlightClass="viewer-ruler-label-highlighted";this._prefix=cfg.prefix||"";this._x=0;this._y=0;this._visible=true;this._culled=false;this._label=document.createElement('div');this._label.className+=this._label.className?' viewer-ruler-label':'viewer-ruler-label';this._timeout=null;var label=this._label;var style=label.style;style["border-radius"]=5+"px";style.color="white";style.padding="4px";style.border="solid 1px";style.background="lightgreen";style.position="absolute";style["z-index"]=cfg.zIndex===undefined?"5000005":cfg.zIndex;style.width="auto";style.height="auto";style.visibility="visible";style.top=0+"px";style.left=0+"px";style["pointer-events"]="all";style["opacity"]=1.0;if(cfg.onContextMenu);label.innerText="";parentElement.appendChild(label);this.setPos(cfg.x||0,cfg.y||0);this.setFillColor(cfg.fillColor);this.setBorderColor(cfg.fillColor);this.setText(cfg.text);if(cfg.onMouseOver){label.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this14);event.preventDefault();});}if(cfg.onMouseLeave){label.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this14);event.preventDefault();});}if(cfg.onMouseWheel){label.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this14);});}if(cfg.onMouseDown){label.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this14);event.stopPropagation();});}if(cfg.onMouseUp){label.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this14);event.stopPropagation();});}if(cfg.onMouseMove){label.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this14);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this14);};addContextMenuListener(label,contextMenuCallback);}}_createClass(Label,[{key:"setPos",value:function setPos(x,y){this._x=x;this._y=y;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosOnWire",value:function setPosOnWire(x1,y1,x2,y2){var x=x1+(x2-x1)*0.5;var y=y1+(y2-y1)*0.5;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setPosBetweenWires",value:function setPosBetweenWires(x1,y1,x2,y2,x3,y3){var x=(x1+x2+x3)/3;var y=(y1+y2+y3)/3;var style=this._label.style;style["left"]=Math.round(x)-20+'px';style["top"]=Math.round(y)-12+'px';}},{key:"setText",value:function setText(text){this._label.innerHTML=this._prefix+(text||"");}},{key:"setFillColor",value:function setFillColor(color){this._fillColor=color||"lightgreen";this._label.style.background=this._fillColor;}},{key:"setBorderColor",value:function setBorderColor(color){this._borderColor=color||"black";this._label.style.border="solid 1px "+this._borderColor;}},{key:"setOpacity",value:function setOpacity(opacity){this._label.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._label.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._label.classList.add(this._highlightClass);}else{this._label.classList.remove(this._highlightClass);}}},{key:"setClickable",value:function setClickable(clickable){this._label.style["pointer-events"]=clickable?"all":"none";}},{key:"setPrefix",value:function setPrefix(prefix){if(this._prefix===prefix){return;}this._prefix=prefix;}},{key:"destroy",value:function destroy(){if(this._label.parentElement){this._label.parentElement.removeChild(this._label);}}}]);return Label;}();/** @private */var Wire=/*#__PURE__*/function(){function Wire(parentElement){var _this15=this;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Wire);this._color=cfg.color||"black";this._highlightClass="viewer-ruler-wire-highlighted";this._wire=document.createElement('div');this._wire.className+=this._wire.className?' viewer-ruler-wire':'viewer-ruler-wire';this._wireClickable=document.createElement('div');this._wireClickable.className+=this._wireClickable.className?' viewer-ruler-wire-clickable':'viewer-ruler-wire-clickable';this._thickness=cfg.thickness||1.0;this._thicknessClickable=cfg.thicknessClickable||6.0;this._visible=true;this._culled=false;var wire=this._wire;var wireStyle=wire.style;wireStyle.border="solid "+this._thickness+"px "+this._color;wireStyle.position="absolute";wireStyle["z-index"]=cfg.zIndex===undefined?"2000001":cfg.zIndex;wireStyle.width=0+"px";wireStyle.height=0+"px";wireStyle.visibility="visible";wireStyle.top=0+"px";wireStyle.left=0+"px";wireStyle['-webkit-transform-origin']="0 0";wireStyle['-moz-transform-origin']="0 0";wireStyle['-ms-transform-origin']="0 0";wireStyle['-o-transform-origin']="0 0";wireStyle['transform-origin']="0 0";wireStyle['-webkit-transform']='rotate(0deg)';wireStyle['-moz-transform']='rotate(0deg)';wireStyle['-ms-transform']='rotate(0deg)';wireStyle['-o-transform']='rotate(0deg)';wireStyle['transform']='rotate(0deg)';wireStyle["opacity"]=1.0;wireStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wire);var wireClickable=this._wireClickable;var wireClickableStyle=wireClickable.style;wireClickableStyle.border="solid "+this._thicknessClickable+"px "+this._color;wireClickableStyle.position="absolute";wireClickableStyle["z-index"]=cfg.zIndex===undefined?"2000002":cfg.zIndex+1;wireClickableStyle.width=0+"px";wireClickableStyle.height=0+"px";wireClickableStyle.visibility="visible";wireClickableStyle.top=0+"px";wireClickableStyle.left=0+"px";// wireClickableStyle["pointer-events"] = "none";
|
|
2290
|
+
wireClickableStyle['-webkit-transform-origin']="0 0";wireClickableStyle['-moz-transform-origin']="0 0";wireClickableStyle['-ms-transform-origin']="0 0";wireClickableStyle['-o-transform-origin']="0 0";wireClickableStyle['transform-origin']="0 0";wireClickableStyle['-webkit-transform']='rotate(0deg)';wireClickableStyle['-moz-transform']='rotate(0deg)';wireClickableStyle['-ms-transform']='rotate(0deg)';wireClickableStyle['-o-transform']='rotate(0deg)';wireClickableStyle['transform']='rotate(0deg)';wireClickableStyle["opacity"]=0.0;wireClickableStyle["pointer-events"]="none";if(cfg.onContextMenu);parentElement.appendChild(wireClickable);if(cfg.onMouseOver){wireClickable.addEventListener('mouseover',function(event){cfg.onMouseOver(event,_this15);});}if(cfg.onMouseLeave){wireClickable.addEventListener('mouseleave',function(event){cfg.onMouseLeave(event,_this15);});}if(cfg.onMouseWheel){wireClickable.addEventListener('wheel',function(event){cfg.onMouseWheel(event,_this15);});}if(cfg.onMouseDown){wireClickable.addEventListener('mousedown',function(event){cfg.onMouseDown(event,_this15);});}if(cfg.onMouseUp){wireClickable.addEventListener('mouseup',function(event){cfg.onMouseUp(event,_this15);});}if(cfg.onMouseMove){wireClickable.addEventListener('mousemove',function(event){cfg.onMouseMove(event,_this15);});}if(cfg.onContextMenu){var contextMenuCallback=function contextMenuCallback(event){cfg.onContextMenu(event,_this15);};addContextMenuListener(wireClickable,contextMenuCallback);}this._x1=0;this._y1=0;this._x2=0;this._y2=0;this._update();}_createClass(Wire,[{key:"visible",get:function get(){return this._wire.style.visibility==="visible";}},{key:"_update",value:function _update(){var length=Math.abs(Math.sqrt((this._x1-this._x2)*(this._x1-this._x2)+(this._y1-this._y2)*(this._y1-this._y2)));var angle=Math.atan2(this._y2-this._y1,this._x2-this._x1)*180.0/Math.PI;var wireStyle=this._wire.style;wireStyle["width"]=Math.round(length)+'px';wireStyle["left"]=Math.round(this._x1)+'px';wireStyle["top"]=Math.round(this._y1)+'px';wireStyle['-webkit-transform']=wireStyle['-moz-transform']=wireStyle['-ms-transform']=wireStyle['-o-transform']=wireStyle['transform']='rotate('+angle+'deg) translate(-'+this._thickness+'px, -'+this._thickness+'px)';var wireClickableStyle=this._wireClickable.style;wireClickableStyle["width"]=Math.round(length)+'px';wireClickableStyle["left"]=Math.round(this._x1)+'px';wireClickableStyle["top"]=Math.round(this._y1)+'px';wireClickableStyle['-webkit-transform']=wireClickableStyle['-moz-transform']=wireClickableStyle['-ms-transform']=wireClickableStyle['-o-transform']=wireClickableStyle['transform']='rotate('+angle+'deg) translate(-'+this._thicknessClickable+'px, -'+this._thicknessClickable+'px)';}},{key:"setStartAndEnd",value:function setStartAndEnd(x1,y1,x2,y2){this._x1=x1;this._y1=y1;this._x2=x2;this._y2=y2;this._update();}},{key:"setColor",value:function setColor(color){this._color=color||"black";this._wire.style.border="solid "+this._thickness+"px "+this._color;}},{key:"setOpacity",value:function setOpacity(opacity){this._wire.style.opacity=opacity;}},{key:"_updateVisibility",value:function _updateVisibility(){this._wire.style.visibility=this._wireClickable.style.visibility=this._visible&&!this._culled?"visible":"hidden";}},{key:"setVisible",value:function setVisible(visible){if(this._visible===visible){return;}this._visible=!!visible;this._updateVisibility();}},{key:"setCulled",value:function setCulled(culled){if(this._culled===culled){return;}this._culled=!!culled;this._updateVisibility();}},{key:"setClickable",value:function setClickable(clickable){this._wireClickable.style["pointer-events"]=clickable?"all":"none";}},{key:"setHighlighted",value:function setHighlighted(highlighted){if(this._highlighted===highlighted){return;}this._highlighted=!!highlighted;if(this._highlighted){this._wire.classList.add(this._highlightClass);}else{this._wire.classList.remove(this._highlightClass);}}},{key:"destroy",value:function destroy(visible){if(this._wire.parentElement){this._wire.parentElement.removeChild(this._wire);}if(this._wireClickable.parentElement){this._wireClickable.parentElement.removeChild(this._wireClickable);}}}]);return Wire;}();var tempVec3a$M=math.vec3();var tempVec4$1=math.vec4();/**
|
|
2290
2291
|
* Given a view matrix and a relative-to-center (RTC) coordinate origin, returns a view matrix
|
|
2291
2292
|
* to transform RTC coordinates to View-space.
|
|
2292
2293
|
*
|
|
@@ -2320,7 +2321,7 @@ wireClickableStyle['-webkit-transform-origin']="0 0";wireClickableStyle['-moz-tr
|
|
|
2320
2321
|
* @returns {Boolean} ````True```` if the positions actually needed conversion to RTC, else ````false````. When
|
|
2321
2322
|
* ````false````, we can safely ignore the data returned in ````rtcPositions```` and ````rtcCenter````,
|
|
2322
2323
|
* since ````rtcCenter```` will equal ````[0,0,0]````, and ````rtcPositions```` will contain identical values to ````positions````.
|
|
2323
|
-
*/function worldToRTCPositions(worldPositions,rtcPositions,rtcCenter){var cellSize=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1000;var center=math.getPositionsCenter(worldPositions,tempVec3a$
|
|
2324
|
+
*/function worldToRTCPositions(worldPositions,rtcPositions,rtcCenter){var cellSize=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1000;var center=math.getPositionsCenter(worldPositions,tempVec3a$M);var rtcCenterX=Math.round(center[0]/cellSize)*cellSize;var rtcCenterY=Math.round(center[1]/cellSize)*cellSize;var rtcCenterZ=Math.round(center[2]/cellSize)*cellSize;rtcCenter[0]=rtcCenterX;rtcCenter[1]=rtcCenterY;rtcCenter[2]=rtcCenterZ;var rtcNeeded=rtcCenter[0]!==0||rtcCenter[1]!==0||rtcCenter[2]!==0;if(rtcNeeded){for(var _i29=0,len=worldPositions.length;_i29<len;_i29+=3){rtcPositions[_i29+0]=worldPositions[_i29+0]-rtcCenterX;rtcPositions[_i29+1]=worldPositions[_i29+1]-rtcCenterY;rtcPositions[_i29+2]=worldPositions[_i29+2]-rtcCenterZ;}}return rtcNeeded;}/**
|
|
2324
2325
|
* Converts an RTC 3D position to World-space.
|
|
2325
2326
|
*
|
|
2326
2327
|
* @private
|
|
@@ -2337,7 +2338,7 @@ wireClickableStyle['-webkit-transform-origin']="0 0";wireClickableStyle['-moz-tr
|
|
|
2337
2338
|
* @param rtcCenter
|
|
2338
2339
|
* @param rtcPlanePos
|
|
2339
2340
|
* @returns {*}
|
|
2340
|
-
*/function getPlaneRTCPos(dist,dir,rtcOrigin,rtcPlanePos,originMatrix){var rtcCenter=originMatrix?(tempVec4$1.set(rtcOrigin,0),tempVec4$1[3]=1,math.mulMat4v4(originMatrix,tempVec4$1,tempVec4$1)):rtcOrigin;var rtcCenterToPlaneDist=math.dotVec3(dir,rtcCenter)+dist;var dirNormalized=math.normalizeVec3(dir,tempVec3a$
|
|
2341
|
+
*/function getPlaneRTCPos(dist,dir,rtcOrigin,rtcPlanePos,originMatrix){var rtcCenter=originMatrix?(tempVec4$1.set(rtcOrigin,0),tempVec4$1[3]=1,math.mulMat4v4(originMatrix,tempVec4$1,tempVec4$1)):rtcOrigin;var rtcCenterToPlaneDist=math.dotVec3(dir,rtcCenter)+dist;var dirNormalized=math.normalizeVec3(dir,tempVec3a$M);math.mulVec3Scalar(dirNormalized,-rtcCenterToPlaneDist,rtcPlanePos);return rtcPlanePos;}/**
|
|
2341
2342
|
* @private
|
|
2342
2343
|
* @type {{PICKABLE: number, CLIPPABLE: number, BACKFACES: number, VISIBLE: number, SELECTED: number, OUTLINED: number, CULLED: number, RECEIVE_SHADOW: number, COLLIDABLE: number, XRAYED: number, CAST_SHADOW: number, EDGES: number, HIGHLIGHTED: number}}
|
|
2343
2344
|
*/var ENTITY_FLAGS={VISIBLE:1,CULLED:1<<2,PICKABLE:1<<3,CLIPPABLE:1<<4,COLLIDABLE:1<<5,CAST_SHADOW:1<<6,RECEIVE_SHADOW:1<<7,XRAYED:1<<8,HIGHLIGHTED:1<<9,SELECTED:1<<10,EDGES:1<<11,BACKFACES:1<<12,TRANSPARENT:1<<13};var tempFloatRGB=new Float32Array([0,0,0]);var tempIntRGB=new Uint16Array([0,0,0]);math.OBB3();/**
|
|
@@ -2580,7 +2581,7 @@ if(lastOpacityQuantized===opacityQuantized){return;}}else{opacityQuantized=255.0
|
|
|
2580
2581
|
* SceneModelEntity contains triangle meshes; returns `0` otherwise.
|
|
2581
2582
|
*
|
|
2582
2583
|
* @returns {number}
|
|
2583
|
-
*/},{key:"surfaceArea",get:function get(){var surfaceArea=0;for(var _i43=0,len=this.meshes.length;_i43<len;_i43++){var _meshSurfaceArea=this.meshes[_i43].surfaceArea;if(_meshSurfaceArea>=0){surfaceArea+=_meshSurfaceArea;}}return surfaceArea>0?surfaceArea:-1;}},{key:"_getFlag",value:function _getFlag(flag){return!!(this._flags&flag);}},{key:"_finalize",value:function _finalize(){var scene=this.model.scene;if(this._isObject){if(this.visible){scene._objectVisibilityUpdated(this);}if(this.highlighted){scene._objectHighlightedUpdated(this);}if(this.xrayed){scene._objectXRayedUpdated(this);}if(this.selected){scene._objectSelectedUpdated(this);}}for(var _i44=0,len=this.meshes.length;_i44<len;_i44++){this.meshes[_i44]._finalize(this._flags);}}},{key:"_finalize2",value:function _finalize2(){for(var _i45=0,len=this.meshes.length;_i45<len;_i45++){this.meshes[_i45]._finalize2();}}},{key:"_destroy",value:function _destroy(){var scene=this.model.scene;if(this._isObject){scene._deregisterObject(this);if(this.visible){scene._deRegisterVisibleObject(this);}if(this.xrayed){scene._deRegisterXRayedObject(this);}if(this.selected){scene._deRegisterSelectedObject(this);}if(this.highlighted){scene._deRegisterHighlightedObject(this);}if(this._colorizeUpdated){this.scene._deRegisterColorizedObject(this);}if(this._opacityUpdated){this.scene._deRegisterOpacityObject(this);}if(this._offset&&(this._offset[0]!==0||this._offset[1]!==0||this._offset[2]!==0)){this.scene._deRegisterOffsetObject(this);}}for(var _i46=0,len=this.meshes.length;_i46<len;_i46++){this.meshes[_i46]._destroy();}scene._aabbDirty=true;}}]);return SceneModelEntity;}();var tempVec4a$
|
|
2584
|
+
*/},{key:"surfaceArea",get:function get(){var surfaceArea=0;for(var _i43=0,len=this.meshes.length;_i43<len;_i43++){var _meshSurfaceArea=this.meshes[_i43].surfaceArea;if(_meshSurfaceArea>=0){surfaceArea+=_meshSurfaceArea;}}return surfaceArea>0?surfaceArea:-1;}},{key:"_getFlag",value:function _getFlag(flag){return!!(this._flags&flag);}},{key:"_finalize",value:function _finalize(){var scene=this.model.scene;if(this._isObject){if(this.visible){scene._objectVisibilityUpdated(this);}if(this.highlighted){scene._objectHighlightedUpdated(this);}if(this.xrayed){scene._objectXRayedUpdated(this);}if(this.selected){scene._objectSelectedUpdated(this);}}for(var _i44=0,len=this.meshes.length;_i44<len;_i44++){this.meshes[_i44]._finalize(this._flags);}}},{key:"_finalize2",value:function _finalize2(){for(var _i45=0,len=this.meshes.length;_i45<len;_i45++){this.meshes[_i45]._finalize2();}}},{key:"_destroy",value:function _destroy(){var scene=this.model.scene;if(this._isObject){scene._deregisterObject(this);if(this.visible){scene._deRegisterVisibleObject(this);}if(this.xrayed){scene._deRegisterXRayedObject(this);}if(this.selected){scene._deRegisterSelectedObject(this);}if(this.highlighted){scene._deRegisterHighlightedObject(this);}if(this._colorizeUpdated){this.scene._deRegisterColorizedObject(this);}if(this._opacityUpdated){this.scene._deRegisterOpacityObject(this);}if(this._offset&&(this._offset[0]!==0||this._offset[1]!==0||this._offset[2]!==0)){this.scene._deRegisterOffsetObject(this);}}for(var _i46=0,len=this.meshes.length;_i46<len;_i46++){this.meshes[_i46]._destroy();}scene._aabbDirty=true;}}]);return SceneModelEntity;}();var tempVec4a$c=math.vec4();var tempVec4b$7=math.vec4();/**
|
|
2584
2585
|
* @desc Tracks the World, View and Canvas coordinates, and visibility, of a position within a {@link Scene}.
|
|
2585
2586
|
*
|
|
2586
2587
|
* ## Position
|
|
@@ -2692,7 +2693,7 @@ if(lastOpacityQuantized===opacityQuantized){return;}}else{opacityQuantized=255.0
|
|
|
2692
2693
|
* @param {Boolean} [cfg.occludable=false] Indicates whether or not this Marker is hidden (ie. {@link Marker#visible} is ````false```` whenever occluded by {@link Entity}s in the {@link Scene}.
|
|
2693
2694
|
* @param {Number[]} [cfg.worldPos=[0,0,0]] World-space 3D Marker position.
|
|
2694
2695
|
*/function Marker(owner,cfg){var _this16;_classCallCheck(this,Marker);_this16=_super4.call(this,owner,cfg);_this16._entity=null;_this16._visible=null;_this16._worldPos=math.vec3();_this16._origin=math.vec3();_this16._rtcPos=math.vec3();_this16._viewPos=math.vec3();_this16._canvasPos=math.vec2();_this16._occludable=false;_this16._onCameraViewMatrix=_this16.scene.camera.on("matrix",function(){_this16._viewPosDirty=true;_this16._needUpdate();});_this16._onCameraProjMatrix=_this16.scene.camera.on("projMatrix",function(){_this16._canvasPosDirty=true;_this16._needUpdate();});_this16._onEntityDestroyed=null;_this16._onEntityModelDestroyed=null;_this16._renderer.addMarker(_assertThisInitialized(_this16));_this16.entity=cfg.entity;_this16.worldPos=cfg.worldPos;_this16.occludable=cfg.occludable;return _this16;}_createClass(Marker,[{key:"_update",value:function _update(){// this._needUpdate() schedules this for next tick
|
|
2695
|
-
if(this._viewPosDirty){math.transformPoint3(this.scene.camera.viewMatrix,this._worldPos,this._viewPos);this._viewPosDirty=false;this._canvasPosDirty=true;this.fire("viewPos",this._viewPos);}if(this._canvasPosDirty){tempVec4a$
|
|
2696
|
+
if(this._viewPosDirty){math.transformPoint3(this.scene.camera.viewMatrix,this._worldPos,this._viewPos);this._viewPosDirty=false;this._canvasPosDirty=true;this.fire("viewPos",this._viewPos);}if(this._canvasPosDirty){tempVec4a$c.set(this._viewPos);tempVec4a$c[3]=1.0;math.transformPoint4(this.scene.camera.projMatrix,tempVec4a$c,tempVec4b$7);var aabb=this.scene.canvas.boundary;this._canvasPos[0]=Math.floor((1+tempVec4b$7[0]/tempVec4b$7[3])*aabb[2]/2);this._canvasPos[1]=Math.floor((1-tempVec4b$7[1]/tempVec4b$7[3])*aabb[3]/2);this._canvasPosDirty=false;this.fire("canvasPos",this._canvasPos);}}},{key:"_setVisible",value:function _setVisible(visible){// Called by VisibilityTester and this._entity.on("destroyed"..)
|
|
2696
2697
|
if(this._visible===visible);this._visible=visible;this.fire("visible",this._visible);}/**
|
|
2697
2698
|
* Sets the {@link Entity} this Marker is associated with.
|
|
2698
2699
|
*
|
|
@@ -3358,7 +3359,7 @@ var onCanvasTouchMove=function onCanvasTouchMove(event){var touch=_toConsumableA
|
|
|
3358
3359
|
* Destroys this AngleMeasurementsPlugin.
|
|
3359
3360
|
*
|
|
3360
3361
|
* Destroys all {@link AngleMeasurement}s first.
|
|
3361
|
-
*/},{key:"destroy",value:function destroy(){this.clear();_get(_getPrototypeOf(AngleMeasurementsPlugin.prototype),"destroy",this).call(this);}}]);return AngleMeasurementsPlugin;}(Plugin);var WAITING_FOR_ORIGIN_TOUCH_START$1=0;var WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1=1;var WAITING_FOR_ORIGIN_LONG_TOUCH_END$1=2;var WAITING_FOR_CORNER_TOUCH_START=3;var WAITING_FOR_CORNER_QUICK_TOUCH_END=4;var WAITING_FOR_CORNER_LONG_TOUCH_END=5;var WAITING_FOR_TARGET_TOUCH_START$1=6;var WAITING_FOR_TARGET_QUICK_TOUCH_END$1=7;var WAITING_FOR_TARGET_LONG_TOUCH_END$1=8;var TOUCH_CANCELING$1=7;/**
|
|
3362
|
+
*/},{key:"destroy",value:function destroy(){this.clear();_get(_getPrototypeOf(AngleMeasurementsPlugin.prototype),"destroy",this).call(this);}}]);return AngleMeasurementsPlugin;}(Plugin);var WAITING_FOR_ORIGIN_TOUCH_START$1=0;var WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1=1;var WAITING_FOR_ORIGIN_LONG_TOUCH_END$1=2;var WAITING_FOR_CORNER_TOUCH_START=3;var WAITING_FOR_CORNER_QUICK_TOUCH_END=4;var WAITING_FOR_CORNER_LONG_TOUCH_END=5;var WAITING_FOR_TARGET_TOUCH_START$1=6;var WAITING_FOR_TARGET_QUICK_TOUCH_END$1=7;var WAITING_FOR_TARGET_LONG_TOUCH_END$1=8;var TOUCH_CANCELING$1=7;var tmpVec2$1=math.vec2();/**
|
|
3362
3363
|
* Creates {@link AngleMeasurement}s from touch input.
|
|
3363
3364
|
*
|
|
3364
3365
|
* See {@link AngleMeasurementsPlugin} for more info.
|
|
@@ -3388,8 +3389,8 @@ var onCanvasTouchMove=function onCanvasTouchMove(event){var touch=_toConsumableA
|
|
|
3388
3389
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3389
3390
|
*/function get(){return this._snapping;}/**
|
|
3390
3391
|
* Activates this AngleMeasurementsTouchControl, ready to respond to input.
|
|
3391
|
-
*/,set:function set(snapping){this._snapping=snapping;}},{key:"activate",value:function activate(){var _this28=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this28._currentAngleMeasurement){_this28._currentAngleMeasurement.destroy();_this28._currentAngleMeasurement=null;}enableCameraNavigation();_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];
|
|
3392
|
-
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this28.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
3392
|
+
*/,set:function set(snapping){this._snapping=snapping;}},{key:"activate",value:function activate(){var _this28=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this28._currentAngleMeasurement){_this28._currentAngleMeasurement.destroy();_this28._currentAngleMeasurement=null;}enableCameraNavigation();_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;};var copyCanvasPos=function copyCanvasPos(event,dst){dst[0]=event.clientX;dst[1]=event.clientY;transformToNode(canvas.ownerDocument.documentElement,canvas,dst);return dst;};var toBodyPos=function toBodyPos(pos,dst){dst.set(pos);transformToNode(canvas,canvas.ownerDocument.documentElement,dst);return dst;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];copyCanvasPos(touch,touchStartCanvasPos);touchMoveCanvasPos.set(touchStartCanvasPos);switch(_this28._touchState){case WAITING_FOR_ORIGIN_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3393
|
+
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this28.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos,tmpVec2$1));}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this28.pointerCircle.start(toBodyPos(pickResult.canvasPos,tmpVec2$1));}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
3393
3394
|
}// Long touch
|
|
3394
3395
|
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.cursorPos=touchStartCanvasPos;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;_this28.pointerLens.snapped=false;}if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.canvasPos;_this28.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.worldPos);
|
|
3395
3396
|
if(!_this28._currentAngleMeasurement){_this28._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},corner:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this28._currentAngleMeasurement.clickable=false;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=false;_this28._currentAngleMeasurement.cornerVisible=false;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;}else{_this28._currentAngleMeasurement.origin.worldPos=pointerWorldPos;}_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);// if (this.pointerLens) {
|
|
@@ -3402,21 +3403,21 @@ touchId=touch.identifier;break;case WAITING_FOR_CORNER_TOUCH_START:if(currentNum
|
|
|
3402
3403
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3403
3404
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3404
3405
|
return;}// Long touch
|
|
3405
|
-
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this28._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.corner.entity=snapPickResult.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{var _pickResult2=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult2&&_pickResult2.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult2.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(_pickResult2.canvasPos);pointerWorldPos.set(_pickResult2.worldPos);_this28._currentAngleMeasurement.corner.worldPos=_pickResult2.worldPos;_this28._currentAngleMeasurement.corner.entity=_pickResult2.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_LONG_TOUCH_END")
|
|
3406
|
+
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos,tmpVec2$1));pointerWorldPos.set(snapPickResult.worldPos);_this28._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.corner.entity=snapPickResult.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{var _pickResult2=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult2&&_pickResult2.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult2.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(toBodyPos(_pickResult2.canvasPos,tmpVec2$1));pointerWorldPos.set(_pickResult2.worldPos);_this28._currentAngleMeasurement.corner.worldPos=_pickResult2.worldPos;_this28._currentAngleMeasurement.corner.entity=_pickResult2.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_LONG_TOUCH_END")
|
|
3406
3407
|
disableCameraNavigation();},_this28._longTouchTimeoutMs);_this28._touchState=WAITING_FOR_CORNER_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_QUICK_TOUCH_END")
|
|
3407
3408
|
}touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3408
3409
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3409
3410
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3410
3411
|
return;}// Long touch
|
|
3411
|
-
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this28._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.target.entity=snapPickResult.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult3.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this28._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this28._currentAngleMeasurement.target.entity=_pickResult3.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3412
|
+
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos,tmpVec2$1));pointerWorldPos.set(snapPickResult.worldPos);_this28._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.target.entity=snapPickResult.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult3.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(toBodyPos(_pickResult3.canvasPos,tmpVec2$1));pointerWorldPos.set(_pickResult3.worldPos);_this28._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this28._currentAngleMeasurement.target.entity=_pickResult3.entity;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;_this28.angleMeasurementsPlugin.fire("measurementStart",_this28._currentAngleMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3412
3413
|
disableCameraNavigation();},_this28._longTouchTimeoutMs);_this28._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
3413
3414
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this28._touchState=TOUCH_CANCELING$1;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
3414
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this28.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];
|
|
3415
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this28.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];if(touch.identifier!==touchId){return;}copyCanvasPos(touch,touchMoveCanvasPos);var snapPickResult;var pickResult;switch(_this28._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this28._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this28._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END$1;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
3415
3416
|
break;case WAITING_FOR_CORNER_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3416
3417
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this28.pointerLens){_this28.pointerLens.visible=false;}_this28._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_CORNER -> TOUCH_CANCELING")
|
|
3417
3418
|
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentAngleMeasurement.corner.worldPos=pickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;}}_this28._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;break;case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3418
3419
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this28.pointerLens){_this28.pointerLens.visible=false;}_this28._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
3419
|
-
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this28.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];
|
|
3420
|
+
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=true;_this28._currentAngleMeasurement.cornerVisible=true;_this28._currentAngleMeasurement.cornerWireVisible=true;_this28._currentAngleMeasurement.targetVisible=true;_this28._currentAngleMeasurement.targetWireVisible=true;_this28._currentAngleMeasurement.angleVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this28.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}copyCanvasPos(touch,touchEndCanvasPos);var touchX=touchEndCanvasPos[0];var touchY=touchEndCanvasPos[1];switch(_this28._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this28._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},corner:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos}});_this28._currentAngleMeasurement.clickable=false;_this28._currentAngleMeasurement.originVisible=true;_this28._currentAngleMeasurement.originWireVisible=false;_this28._currentAngleMeasurement.cornerVisible=false;_this28._currentAngleMeasurement.cornerWireVisible=false;_this28._currentAngleMeasurement.targetVisible=false;_this28._currentAngleMeasurement.targetWireVisible=false;_this28._currentAngleMeasurement.angleVisible=false;_this28._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_CORNER_TOUCH_START")
|
|
3420
3421
|
}else{if(_this28._currentAngleMeasurement){_this28._currentAngleMeasurement.destroy();_this28._currentAngleMeasurement=null;}_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3421
3422
|
}}enableCameraNavigation();break;case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this28.pointerLens){_this28.pointerLens.visible=false;}if(!_this28._currentAngleMeasurement){if(_this28.pointerLens){_this28.pointerLens.snapped=false;_this28.pointerLens.visible=false;}_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (no measurement) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3422
3423
|
}else{_this28._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (picked, begin measurement) -> WAITING_FOR_CORNER_TOUCH_START")
|
|
@@ -3453,7 +3454,7 @@ enableCameraNavigation();break;case WAITING_FOR_TARGET_QUICK_TOUCH_END$1:{if(num
|
|
|
3453
3454
|
* @param {boolean} [handleTouchEvents] Whether to hangle touch input.
|
|
3454
3455
|
*/function AngleMeasurementEditControl(measurement,cfg,handleMouseEvents,handleTouchEvents){var _this29;_classCallCheck(this,AngleMeasurementEditControl);var viewer=measurement.plugin.viewer;_this29=_super11.call(this,viewer.scene);var cleanup=activateDraggableDots({viewer:viewer,handleMouseEvents:handleMouseEvents,handleTouchEvents:handleTouchEvents,pointerLens:cfg.pointerLens,dots:[measurement.origin,measurement.corner,measurement.target],ray2WorldPos:function ray2WorldPos(orig,dir,canvasPos){var tryPickWorldPos=function tryPickWorldPos(snap){var pickResult=viewer.scene.pick({canvasPos:canvasPos,snapToEdge:snap,snapToVertex:snap,pickSurface:true// <<------ This causes picking to find the intersection point on the entity
|
|
3455
3456
|
});// If - when snapping - no pick found, then try w/o snapping
|
|
3456
|
-
return pickResult&&pickResult.worldPos?pickResult.worldPos:snap&&tryPickWorldPos(false);};return tryPickWorldPos(!!cfg.snapping);},onEnd:function onEnd(initPos,dot){var changed=!math.compareVec3(initPos,dot.worldPos);if(changed){_this29.fire("edited");}return changed;}});var destroyCb=measurement.on("destroyed",cleanup);_this29._deactivate=function(){measurement.off("destroyed",destroyCb);cleanup();};return _this29;}_createClass(AngleMeasurementEditControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(AngleMeasurementEditControl.prototype),"destroy",this).call(this);}}]);return AngleMeasurementEditControl;}(Component);var AngleMeasurementEditMouseControl=/*#__PURE__*/function(_AngleMeasurementEdit){_inherits(AngleMeasurementEditMouseControl,_AngleMeasurementEdit);var _super12=_createSuper(AngleMeasurementEditMouseControl);function AngleMeasurementEditMouseControl(zone,cfg){_classCallCheck(this,AngleMeasurementEditMouseControl);return _super12.call(this,zone,cfg,true,false);}return _createClass(AngleMeasurementEditMouseControl);}(AngleMeasurementEditControl);var AngleMeasurementEditTouchControl=/*#__PURE__*/function(_AngleMeasurementEdit2){_inherits(AngleMeasurementEditTouchControl,_AngleMeasurementEdit2);var _super13=_createSuper(AngleMeasurementEditTouchControl);function AngleMeasurementEditTouchControl(zone,cfg){_classCallCheck(this,AngleMeasurementEditTouchControl);return _super13.call(this,zone,cfg,false,true);}return _createClass(AngleMeasurementEditTouchControl);}(AngleMeasurementEditControl);var tempVec3a$
|
|
3457
|
+
return pickResult&&pickResult.worldPos?pickResult.worldPos:snap&&tryPickWorldPos(false);};return tryPickWorldPos(!!cfg.snapping);},onEnd:function onEnd(initPos,dot){var changed=!math.compareVec3(initPos,dot.worldPos);if(changed){_this29.fire("edited");}return changed;}});var destroyCb=measurement.on("destroyed",cleanup);_this29._deactivate=function(){measurement.off("destroyed",destroyCb);cleanup();};return _this29;}_createClass(AngleMeasurementEditControl,[{key:"deactivate",value:function deactivate(){this._deactivate();_get(_getPrototypeOf(AngleMeasurementEditControl.prototype),"destroy",this).call(this);}}]);return AngleMeasurementEditControl;}(Component);var AngleMeasurementEditMouseControl=/*#__PURE__*/function(_AngleMeasurementEdit){_inherits(AngleMeasurementEditMouseControl,_AngleMeasurementEdit);var _super12=_createSuper(AngleMeasurementEditMouseControl);function AngleMeasurementEditMouseControl(zone,cfg){_classCallCheck(this,AngleMeasurementEditMouseControl);return _super12.call(this,zone,cfg,true,false);}return _createClass(AngleMeasurementEditMouseControl);}(AngleMeasurementEditControl);var AngleMeasurementEditTouchControl=/*#__PURE__*/function(_AngleMeasurementEdit2){_inherits(AngleMeasurementEditTouchControl,_AngleMeasurementEdit2);var _super13=_createSuper(AngleMeasurementEditTouchControl);function AngleMeasurementEditTouchControl(zone,cfg){_classCallCheck(this,AngleMeasurementEditTouchControl);return _super13.call(this,zone,cfg,false,true);}return _createClass(AngleMeasurementEditTouchControl);}(AngleMeasurementEditControl);var tempVec3a$L=math.vec3();var tempVec3b$A=math.vec3();var tempVec3c$v=math.vec3();/**
|
|
3457
3458
|
* A {@link Marker} with an HTML label attached to it, managed by an {@link AnnotationsPlugin}.
|
|
3458
3459
|
*
|
|
3459
3460
|
* See {@link AnnotationsPlugin} for more info.
|
|
@@ -3491,7 +3492,7 @@ return pickResult&&pickResult.worldPos?pickResult.worldPos:snap&&tryPickWorldPos
|
|
|
3491
3492
|
*/_this30.projection=cfg.projection;return _this30;}/**
|
|
3492
3493
|
* @private
|
|
3493
3494
|
*/_createClass(Annotation,[{key:"_buildHTML",value:function _buildHTML(){var _this31=this;if(!this._markerExternal){if(this._marker){this._container.removeChild(this._marker);this._marker=null;}var markerHTML=this._markerHTML||"<p></p>";// Make marker
|
|
3494
|
-
if(utils.isArray(markerHTML)){markerHTML=markerHTML.join("");}markerHTML=this._renderTemplate(markerHTML.trim());var markerFragment=document.createRange().createContextualFragment(markerHTML);this._marker=markerFragment.firstChild;this._container.appendChild(this._marker);this._marker.style.visibility=this._markerShown?"visible":"hidden";this._marker.addEventListener("click",function(){_this31.plugin.fire("markerClicked",_this31);});addContextMenuListener(this._marker,function(e){e.preventDefault();_this31.plugin.fire("contextmenu",_this31);});this._marker.addEventListener("mouseenter",function(){_this31.plugin.fire("markerMouseEnter",_this31);});this._marker.addEventListener("mouseleave",function(){_this31.plugin.fire("markerMouseLeave",_this31);});this._marker.addEventListener('wheel',function(event){_this31.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel',event));});}if(!this._labelExternal){if(this._label){this._container.removeChild(this._label);this._label=null;}var labelHTML=this._labelHTML||"<p></p>";// Make label
|
|
3495
|
+
if(utils.isArray(markerHTML)){markerHTML=markerHTML.join("");}markerHTML=this._renderTemplate(markerHTML.trim());var markerFragment=document.createRange().createContextualFragment(markerHTML);this._marker=markerFragment.firstChild;this._container.appendChild(this._marker);this._marker.style.visibility=this._markerShown?"visible":"hidden";this._marker.addEventListener("click",function(){_this31.plugin.fire("markerClicked",_this31);});addContextMenuListener(this._marker,function(e){e.preventDefault();_this31.plugin.fire("contextmenu",_this31);},function(e){e.preventDefault();_this31.plugin.fire("markerClicked",_this31);});this._marker.addEventListener("mouseenter",function(){_this31.plugin.fire("markerMouseEnter",_this31);});this._marker.addEventListener("mouseleave",function(){_this31.plugin.fire("markerMouseLeave",_this31);});this._marker.addEventListener('wheel',function(event){_this31.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel',event));});}if(!this._labelExternal){if(this._label){this._container.removeChild(this._label);this._label=null;}var labelHTML=this._labelHTML||"<p></p>";// Make label
|
|
3495
3496
|
if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._renderTemplate(labelHTML.trim());var labelFragment=document.createRange().createContextualFragment(labelHTML);this._label=labelFragment.firstChild;this._container.appendChild(this._label);this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden";this._label.addEventListener('wheel',function(event){_this31.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel',event));});}}/**
|
|
3496
3497
|
* @private
|
|
3497
3498
|
*/},{key:"_updatePosition",value:function _updatePosition(){var px=function px(x){return x+"px";};var boundary=this.scene.canvas.boundary;var left=boundary[0]+this.canvasPos[0];var top=boundary[1]+this.canvasPos[1];var markerRect=this._marker.getBoundingClientRect();var markerWidth=markerRect.width;var markerDir=this._markerAlign==="right"?-1:this._markerAlign==="center"?0:1;var markerCenter=left+markerDir*(markerWidth/2-12);this._marker.style.left=px(markerCenter-markerWidth/2);this._marker.style.top=px(top-12);this._marker.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;var labelRect=this._label.getBoundingClientRect();var labelWidth=labelRect.width;var labelDir=Math.sign(this._labelPosition);this._label.style.left=px(markerCenter+labelDir*(markerWidth/2+Math.abs(this._labelPosition)+labelWidth/2)-labelWidth/2);this._label.style.top=px(top-17);this._label.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;}/**
|
|
@@ -3500,7 +3501,7 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
|
|
|
3500
3501
|
* Sets the Marker's worldPos and entity properties based on passed {@link PickResult}
|
|
3501
3502
|
*
|
|
3502
3503
|
* @param {PickResult} pickResult A PickResult to position the Marker at.
|
|
3503
|
-
*/},{key:"setFromPickResult",value:function setFromPickResult(pickResult){if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$
|
|
3504
|
+
*/},{key:"setFromPickResult",value:function setFromPickResult(pickResult){if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$L);var offset=this.plugin&&this.plugin.surfaceOffset||0;var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,offset,tempVec3b$A);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$v);this.entity=pickResult.entity;this.worldPos=offsetWorldPos;}}/**
|
|
3504
3505
|
* Sets the horizontal alignment of the Annotation's marker HTML.
|
|
3505
3506
|
*
|
|
3506
3507
|
* @param {String} align Either "left", "center", "right" (default "left")
|
|
@@ -4719,7 +4720,7 @@ this._buildPositions();this.positionsDirty=false;this.aabbDirty=true;this.vbosDi
|
|
|
4719
4720
|
this.positionsBuf.setData(new Float32Array(this.positions));// Indices don't need updating
|
|
4720
4721
|
return;}this.positionsBuf.destroy();this.positionsBuf=null;this.indicesBuf.destroy();this.indicesBuf=null;}var gl=this.scene.canvas.gl;var lenPositions=this.numMarkers*3;var lenIndices=this.numMarkers;this.positionsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this.positions),lenPositions,3,gl.STATIC_DRAW);this.indicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),lenIndices,1,gl.STATIC_DRAW);this.lenPositionsBuf=this.positions.length;}},{key:"_buildOcclusionTestList",value:function _buildOcclusionTestList(){var canvas=this.scene.canvas;var near=this.scene.camera.perspective.near;// Assume near enough to ortho near
|
|
4721
4722
|
var boundary=canvas.boundary;var canvasWidth=boundary[2];var canvasHeight=boundary[3];var lenPixels=0;this.lenOcclusionTestList=0;for(var _i53=0;_i53<this.numMarkers;_i53++){var marker=this.markerList[_i53];var _viewPos=marker.viewPos;if(_viewPos[2]>-near){// Clipped by near plane
|
|
4722
|
-
marker._setVisible(false);continue;}var _canvasPos2=marker.canvasPos;var canvasX=_canvasPos2[0];var canvasY=_canvasPos2[1];if(canvasX+10<0||canvasY+10<0||canvasX-10>canvasWidth||canvasY-10>canvasHeight){marker._setVisible(false);continue;}if(marker.entity&&!marker.entity.visible){marker._setVisible(false);continue;}if(marker.occludable){this.occlusionTestList[this.lenOcclusionTestList++]=marker;this.pixels[lenPixels++]=canvasX;this.pixels[lenPixels++]=canvasY;continue;}marker._setVisible(true);}}},{key:"_updateActiveSectionPlanes",value:function _updateActiveSectionPlanes(){var sectionPlanes=this.scene._sectionPlanesState.sectionPlanes;var numSectionPlanes=sectionPlanes.length;if(numSectionPlanes>0){for(var _i54=0;_i54<numSectionPlanes;_i54++){var sectionPlane=sectionPlanes[_i54];if(!sectionPlane.active){this.sectionPlanesActive[_i54]=false;}else{var intersect=math.planeAABB3Intersect(sectionPlane.dir,sectionPlane.dist,this.aabb);var outside=intersect===-1;if(outside){this.culledBySectionPlanes=true;return;}var intersecting=intersect===0;this.sectionPlanesActive[_i54]=intersecting;}}}this.culledBySectionPlanes=false;}},{key:"destroy",value:function destroy(){this.markers={};this.markerList.length=0;if(this.positionsBuf){this.positionsBuf.destroy();}if(this.indicesBuf){this.indicesBuf.destroy();}}}]);return OcclusionLayer;}();var MARKER_COLOR=math.vec3([1.0,0.0,0.0]);var POINT_SIZE=20;var tempVec3a$
|
|
4723
|
+
marker._setVisible(false);continue;}var _canvasPos2=marker.canvasPos;var canvasX=_canvasPos2[0];var canvasY=_canvasPos2[1];if(canvasX+10<0||canvasY+10<0||canvasX-10>canvasWidth||canvasY-10>canvasHeight){marker._setVisible(false);continue;}if(marker.entity&&!marker.entity.visible){marker._setVisible(false);continue;}if(marker.occludable){this.occlusionTestList[this.lenOcclusionTestList++]=marker;this.pixels[lenPixels++]=canvasX;this.pixels[lenPixels++]=canvasY;continue;}marker._setVisible(true);}}},{key:"_updateActiveSectionPlanes",value:function _updateActiveSectionPlanes(){var sectionPlanes=this.scene._sectionPlanesState.sectionPlanes;var numSectionPlanes=sectionPlanes.length;if(numSectionPlanes>0){for(var _i54=0;_i54<numSectionPlanes;_i54++){var sectionPlane=sectionPlanes[_i54];if(!sectionPlane.active){this.sectionPlanesActive[_i54]=false;}else{var intersect=math.planeAABB3Intersect(sectionPlane.dir,sectionPlane.dist,this.aabb);var outside=intersect===-1;if(outside){this.culledBySectionPlanes=true;return;}var intersecting=intersect===0;this.sectionPlanesActive[_i54]=intersecting;}}}this.culledBySectionPlanes=false;}},{key:"destroy",value:function destroy(){this.markers={};this.markerList.length=0;if(this.positionsBuf){this.positionsBuf.destroy();}if(this.indicesBuf){this.indicesBuf.destroy();}}}]);return OcclusionLayer;}();var MARKER_COLOR=math.vec3([1.0,0.0,0.0]);var POINT_SIZE=20;var tempVec3a$K=math.vec3();/**
|
|
4723
4724
|
* Manages occlusion testing. Private member of a Renderer.
|
|
4724
4725
|
* @private
|
|
4725
4726
|
*/var OcclusionTester=/*#__PURE__*/function(){function OcclusionTester(scene,renderBufferManager){var _this36=this;_classCallCheck(this,OcclusionTester);this._scene=scene;this._renderBufferManager=renderBufferManager;this._occlusionLayers={};this._occlusionLayersList=[];this._occlusionLayersListDirty=false;this._shaderSource=null;this._program=null;this._shaderSourceHash=null;this._shaderSourceDirty=true;// Need to build shader source code ?
|
|
@@ -4742,7 +4743,7 @@ this._markersToOcclusionLayersMap={};this._onCameraViewMatrix=scene.camera.on("v
|
|
|
4742
4743
|
* then calls drawMarkers() and doOcclusionTest().
|
|
4743
4744
|
*/},{key:"bindRenderBuf",value:function bindRenderBuf(){var shaderSourceHash=[this._scene.canvas.canvas.id,this._scene._sectionPlanesState.getHash()].join(";");if(shaderSourceHash!==this._shaderSourceHash){this._shaderSourceHash=shaderSourceHash;this._shaderSourceDirty=true;}if(this._shaderSourceDirty){this._buildShaderSource();this._shaderSourceDirty=false;this._programDirty=true;}if(this._programDirty){this._buildProgram();this._programDirty=false;this._occlusionTestListDirty=true;}if(this._occlusionLayersListDirty){this._buildOcclusionLayersList();this._occlusionLayersListDirty=false;}if(this._occlusionTestListDirty){for(var _i55=0,len=this._occlusionLayersList.length;_i55<len;_i55++){var occlusionLayer=this._occlusionLayersList[_i55];occlusionLayer.occlusionTestListDirty=true;}this._occlusionTestListDirty=false;}{this._readPixelBuf=this._renderBufferManager.getRenderBuffer("occlusionReadPix");this._readPixelBuf.bind();this._readPixelBuf.clear();}}},{key:"_buildOcclusionLayersList",value:function _buildOcclusionLayersList(){var numOcclusionLayers=0;for(var originHash in this._occlusionLayers){if(this._occlusionLayers.hasOwnProperty(originHash)){this._occlusionLayersList[numOcclusionLayers++]=this._occlusionLayers[originHash];}}this._occlusionLayersList.length=numOcclusionLayers;}},{key:"_buildShaderSource",value:function _buildShaderSource(){this._shaderSource={vertex:this._buildVertexShaderSource(),fragment:this._buildFragmentShaderSource()};}},{key:"_buildVertexShaderSource",value:function _buildVertexShaderSource(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// OcclusionTester vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("void main(void) {");src.push("vec4 worldPosition = vec4(position, 1.0); ");src.push(" vec4 viewPosition = viewMatrix * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push(" vec4 clipPos = projMatrix * viewPosition;");src.push(" gl_PointSize = "+POINT_SIZE+".0;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}else{if(scene.markerZOffset<0.000){src.push("clipPos.z += "+scene.markerZOffset+";");}}src.push(" gl_Position = clipPos;");src.push("}");return src;}},{key:"_buildFragmentShaderSource",value:function _buildFragmentShaderSource(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// OcclusionTester fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");for(var _i56=0;_i56<sectionPlanesState.sectionPlanes.length;_i56++){src.push("uniform bool sectionPlaneActive"+_i56+";");src.push("uniform vec3 sectionPlanePos"+_i56+";");src.push("uniform vec3 sectionPlaneDir"+_i56+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vec4(1.0, 0.0, 0.0, 1.0); ");src.push("}");return src;}},{key:"_buildProgram",value:function _buildProgram(){if(this._program){this._program.destroy();}var scene=this._scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var sectionPlanes=sectionPlanesState.sectionPlanes;for(var _i57=0,len=sectionPlanes.length;_i57<len;_i57++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i57),pos:program.getLocation("sectionPlanePos"+_i57),dir:program.getLocation("sectionPlaneDir"+_i57)});}this._aPosition=program.getAttribute("position");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}/**
|
|
4744
4745
|
* Draws {@link Marker}s to the render buffer.
|
|
4745
|
-
*/},{key:"drawMarkers",value:function drawMarkers(){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var sectionPlanesState=scene._sectionPlanesState;var camera=scene.camera;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var _i58=0,len=this._occlusionLayersList.length;_i58<len;_i58++){var occlusionLayer=this._occlusionLayersList[_i58];occlusionLayer.update();if(occlusionLayer.culledBySectionPlanes){continue;}var origin=occlusionLayer.origin;gl.uniformMatrix4fv(this._uViewMatrix,false,createRTCViewMat(camera.viewMatrix,origin));var numSectionPlanes=sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=sectionPlanesState.sectionPlanes;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=occlusionLayer.sectionPlanesActive[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
4746
|
+
*/},{key:"drawMarkers",value:function drawMarkers(){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var sectionPlanesState=scene._sectionPlanesState;var camera=scene.camera;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var _i58=0,len=this._occlusionLayersList.length;_i58<len;_i58++){var occlusionLayer=this._occlusionLayersList[_i58];occlusionLayer.update();if(occlusionLayer.culledBySectionPlanes){continue;}var origin=occlusionLayer.origin;gl.uniformMatrix4fv(this._uViewMatrix,false,createRTCViewMat(camera.viewMatrix,origin));var numSectionPlanes=sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=sectionPlanesState.sectionPlanes;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=occlusionLayer.sectionPlanesActive[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$K));gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}this._aPosition.bindArrayBuffer(occlusionLayer.positionsBuf);var indicesBuf=occlusionLayer.indicesBuf;indicesBuf.bind();gl.drawElements(gl.POINTS,indicesBuf.numItems,indicesBuf.itemType,0);}}/**
|
|
4746
4747
|
* Sets visibilities of {@link Marker}s according to whether or not they are obscured by anything in the render buffer.
|
|
4747
4748
|
*/},{key:"doOcclusionTest",value:function doOcclusionTest(){{var resolutionScale=this._scene.canvas.resolutionScale;var markerR=MARKER_COLOR[0]*255;var markerG=MARKER_COLOR[1]*255;var markerB=MARKER_COLOR[2]*255;for(var _i59=0,len=this._occlusionLayersList.length;_i59<len;_i59++){var occlusionLayer=this._occlusionLayersList[_i59];for(var _i60=0;_i60<occlusionLayer.lenOcclusionTestList;_i60++){var marker=occlusionLayer.occlusionTestList[_i60];var j=_i60*2;var _color=this._readPixelBuf.read(Math.round(occlusionLayer.pixels[j]*resolutionScale),Math.round(occlusionLayer.pixels[j+1]*resolutionScale));var visible=_color[0]===markerR&&_color[1]===markerG&&_color[2]===markerB;marker._setVisible(visible);}}}}/**
|
|
4748
4749
|
* Unbinds render buffer.
|
|
@@ -4869,12 +4870,12 @@ if(selectedFillTransparentBinLen>0){for(i=0;i<selectedFillTransparentBinLen;i++)
|
|
|
4869
4870
|
for(var _ii=0;_ii<numVertexAttribs;_ii++){gl.disableVertexAttribArray(_ii);}}/**
|
|
4870
4871
|
* Picks an Entity.
|
|
4871
4872
|
* @private
|
|
4872
|
-
*/this.pick=function(){var tempVec3a=math.vec3();math.mat4();var tempMat4b=math.mat4();var randomVec3=math.vec3();var up=math.vec3([0,1,0]);var _pickResult=new PickResult();var nearAndFar=math.vec2();var canvasPos=math.vec3();var worldRayOrigin=math.vec3();var worldRayDir=math.vec3();math.vec3();math.vec3();return function(params){var pickResult=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_pickResult;pickResult.reset();updateDrawlist();var look;var pickViewMatrix=null;var pickProjMatrix=null;var projection=null;pickResult.pickSurface=params.pickSurface;if(params.canvasPos){canvasPos[0]=params.canvasPos[0];canvasPos[1]=params.canvasPos[1];pickViewMatrix=scene.camera.viewMatrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;pickResult.canvasPos=params.canvasPos;}else{// Picking with arbitrary World-space ray
|
|
4873
|
+
*/this.pick=function(){var tempVec3a=math.vec3();math.mat4();var tempMat4b=math.mat4();var randomVec3=math.vec3();var up=math.vec3([0,1,0]);var _pickResult=new PickResult();var nearAndFar=math.vec2();var canvasPos=math.vec3();var worldRayOrigin=math.vec3();var worldRayDir=math.vec3();math.vec3();math.vec3();return function(params){var pickResult=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_pickResult;pickResult.reset();updateDrawlist();var look;var pickViewMatrix=null;var pickProjMatrix=null;var projection=null;pickResult.pickSurface=params.pickSurface;if(params.canvasPos){canvasPos[0]=params.canvasPos[0];canvasPos[1]=params.canvasPos[1];pickViewMatrix=scene.camera.viewMatrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;nearAndFar[0]=scene.camera.project.near;nearAndFar[1]=scene.camera.project.far;pickResult.canvasPos=params.canvasPos;}else{// Picking with arbitrary World-space ray
|
|
4873
4874
|
// Align camera along ray and fire ray through center of canvas
|
|
4874
|
-
if(params.matrix){pickViewMatrix=params.matrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;}else{worldRayOrigin.set(params.origin||[0,0,0]);worldRayDir.set(params.direction||[0,0,1]);look=math.addVec3(worldRayOrigin,worldRayDir,tempVec3a);randomVec3[0]=Math.random();randomVec3[1]=Math.random();randomVec3[2]=Math.random();math.normalizeVec3(randomVec3);math.cross3Vec3(worldRayDir,randomVec3,up);pickViewMatrix=math.lookAtMat4v(worldRayOrigin,look,up,tempMat4b);// pickProjMatrix = scene.camera.projMatrix;
|
|
4875
|
-
pickProjMatrix=scene.camera.ortho.matrix;projection="ortho";pickResult.origin=worldRayOrigin;pickResult.direction=worldRayDir;}canvasPos[0]=canvas.clientWidth*0.5;canvasPos[1]=canvas.clientHeight*0.5;}for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableList=drawableTypeInfo[type].drawableList;for(var _i71=0,len=drawableList.length;_i71<len;_i71++){var drawable=drawableList[_i71];if(drawable.setPickMatrices){// Eg. SceneModel, which needs pre-loading into texture
|
|
4875
|
+
if(params.matrix){pickViewMatrix=params.matrix;pickProjMatrix=scene.camera.projMatrix;projection=scene.camera.projection;nearAndFar[0]=scene.camera.project.near;nearAndFar[1]=scene.camera.project.far;}else{worldRayOrigin.set(params.origin||[0,0,0]);worldRayDir.set(params.direction||[0,0,1]);look=math.addVec3(worldRayOrigin,worldRayDir,tempVec3a);randomVec3[0]=Math.random();randomVec3[1]=Math.random();randomVec3[2]=Math.random();math.normalizeVec3(randomVec3);math.cross3Vec3(worldRayDir,randomVec3,up);pickViewMatrix=math.lookAtMat4v(worldRayOrigin,look,up,tempMat4b);// pickProjMatrix = scene.camera.projMatrix;
|
|
4876
|
+
pickProjMatrix=scene.camera.ortho.matrix;projection="ortho";nearAndFar[0]=scene.camera.ortho.near;nearAndFar[1]=scene.camera.ortho.far;pickResult.origin=worldRayOrigin;pickResult.direction=worldRayDir;}canvasPos[0]=canvas.clientWidth*0.5;canvasPos[1]=canvas.clientHeight*0.5;}for(var type in drawableTypeInfo){if(drawableTypeInfo.hasOwnProperty(type)){var drawableList=drawableTypeInfo[type].drawableList;for(var _i71=0,len=drawableList.length;_i71<len;_i71++){var drawable=drawableList[_i71];if(drawable.setPickMatrices){// Eg. SceneModel, which needs pre-loading into texture
|
|
4876
4877
|
drawable.setPickMatrices(pickViewMatrix,pickProjMatrix);}}}}var pickBuffer=renderBufferManager.getRenderBuffer("pick",{size:[1,1]});pickBuffer.bind();var pickable=gpuPickPickable(pickBuffer,canvasPos,pickViewMatrix,pickProjMatrix,params,pickResult);if(!pickable){pickBuffer.unbind();return null;}var pickedEntity=pickable.delegatePickedEntity?pickable.delegatePickedEntity():pickable;if(!pickedEntity){pickBuffer.unbind();return null;}if(params.pickSurface){// GPU-based ray-picking
|
|
4877
|
-
if(pickable.canPickTriangle&&pickable.canPickTriangle()){gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);pickable.pickTriangleSurface(pickViewMatrix,pickProjMatrix,projection,pickResult);pickResult.pickSurfacePrecision=false;}else{if(pickable.canPickWorldPos&&pickable.canPickWorldPos()){
|
|
4878
|
+
if(pickable.canPickTriangle&&pickable.canPickTriangle()){gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);pickable.pickTriangleSurface(pickViewMatrix,pickProjMatrix,projection,pickResult);pickResult.pickSurfacePrecision=false;}else{if(pickable.canPickWorldPos&&pickable.canPickWorldPos()){gpuPickWorldPos(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,nearAndFar,pickResult);if(params.pickSurfaceNormal!==false){gpuPickWorldNormal(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult);}pickResult.pickSurfacePrecision=false;}}}pickBuffer.unbind();pickResult.entity=pickedEntity;return pickResult;};}();function gpuPickPickable(pickBuffer,canvasPos,pickViewMatrix,pickProjMatrix,params,pickResult){var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4878
4879
|
frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;frameCtx.pickProjMatrix=pickProjMatrix;frameCtx.pickInvisible=!!params.pickInvisible;frameCtx.pickClipPos=[getClipPosX(canvasPos[0]*resolutionScale,gl.drawingBufferWidth),getClipPosY(canvasPos[1]*resolutionScale,gl.drawingBufferHeight)];gl.viewport(0,0,1,1);gl.depthMask(true);gl.enable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);var includeEntityIds=params.includeEntityIds;var excludeEntityIds=params.excludeEntityIds;for(var _i72=0,len=postCullDrawableList.length;_i72<len;_i72++){var drawable=postCullDrawableList[_i72];if(drawable.culled===true||drawable.visible===false){continue;}if(!drawable.drawPickMesh||params.pickInvisible!==true&&drawable.visible===false||drawable.pickable===false){continue;}if(includeEntityIds&&!includeEntityIds[drawable.id]){// TODO: push this logic into drawable
|
|
4879
4880
|
continue;}if(excludeEntityIds&&excludeEntityIds[drawable.id]){continue;}drawable.drawPickMesh(frameCtx);}var pix=pickBuffer.read(0,0);var pickID=pix[0]+(pix[1]<<8)+(pix[2]<<16)+(pix[3]<<24);if(pickID<0){return;}var pickable=pickIDs.items[pickID];return pickable;}function gpuPickTriangle(pickBuffer,pickable,canvasPos,pickViewMatrix,pickProjMatrix,pickResult){if(!pickable.drawPickTriangles){return;}var resolutionScale=scene.canvas.resolutionScale;frameCtx.reset();frameCtx.backfaces=true;frameCtx.frontface=true;// "ccw"
|
|
4880
4881
|
frameCtx.pickOrigin=pickResult.origin;frameCtx.pickViewMatrix=pickViewMatrix;// Can be null
|
|
@@ -6181,7 +6182,7 @@ _this45.left=cfg.left;_this45.right=cfg.right;_this45.bottom=cfg.bottom;_this45.
|
|
|
6181
6182
|
* @param {Number[]} worldPos Outputs un-projected 3D World-space coordinates.
|
|
6182
6183
|
*/},{key:"unproject",value:function unproject(canvasPos,screenZ,screenPos,viewPos,worldPos){var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;screenPos[0]=(canvasPos[0]-halfCanvasWidth)/halfCanvasWidth;screenPos[1]=(canvasPos[1]-halfCanvasHeight)/halfCanvasHeight;screenPos[2]=screenZ;screenPos[3]=1.0;math.mulMat4v4(this.inverseMatrix,screenPos,viewPos);math.mulVec3Scalar(viewPos,1.0/viewPos[3]);viewPos[3]=1.0;viewPos[1]*=-1;math.mulMat4v4(this.camera.inverseViewMatrix,viewPos,worldPos);return worldPos;}/** @private
|
|
6183
6184
|
*
|
|
6184
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$
|
|
6185
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$z=math.vec3();var tempVec3c$u=math.vec3();var tempVec3d$d=math.vec3();var tempVec3e$2=math.vec3();var tempVec3f$2=math.vec3();var tempVec4a$b=math.vec4();var tempVec4b$6=math.vec4();var tempVec4c$2=math.vec4();var tempMat=math.mat4();var tempMatb=math.mat4();var eyeLookVec=math.vec3();var eyeLookVecNorm=math.vec3();var eyeLookOffset=math.vec3();var offsetEye=math.vec3();/**
|
|
6185
6186
|
* @desc Manages viewing and projection transforms for its {@link Scene}.
|
|
6186
6187
|
*
|
|
6187
6188
|
* * One Camera per {@link Scene}
|
|
@@ -6384,29 +6385,29 @@ var eye;if(this.projection==="ortho"){math.subVec3(this._eye,this._look,eyeLookV
|
|
|
6384
6385
|
* Rotates {@link Camera#eye} about {@link Camera#look}, around the {@link Camera#up} vector
|
|
6385
6386
|
*
|
|
6386
6387
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6387
|
-
*/},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$
|
|
6388
|
+
*/},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$z);this.eye=math.addVec3(this._look,lookEyeVec,tempVec3c$u);// Set eye position as 'look' plus 'eye' vector
|
|
6388
6389
|
this.up=math.transformPoint3(tempMat,this._up,tempVec3d$d);// Rotate 'up' vector
|
|
6389
6390
|
}/**
|
|
6390
6391
|
* Rotates {@link Camera#eye} about {@link Camera#look} around the right axis (orthogonal to {@link Camera#up} and "look").
|
|
6391
6392
|
*
|
|
6392
6393
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6393
|
-
*/},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$
|
|
6394
|
+
*/},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$z),math.normalizeVec3(this._up,tempVec3c$u));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$d);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$2);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
|
|
6394
6395
|
* Rotates {@link Camera#look} about {@link Camera#eye}, around the {@link Camera#up} vector.
|
|
6395
6396
|
*
|
|
6396
6397
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6397
|
-
*/},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$
|
|
6398
|
+
*/},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$z);this.look=math.addVec3(look2,this._eye,tempVec3c$u);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$d);}}/**
|
|
6398
6399
|
* Rotates {@link Camera#look} about {@link Camera#eye}, around the right axis (orthogonal to {@link Camera#up} and "look").
|
|
6399
6400
|
|
|
6400
6401
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6401
|
-
*/},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$
|
|
6402
|
+
*/},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$z),math.normalizeVec3(this._up,tempVec3c$u));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$d);this.look=math.addVec3(look2,this._eye,tempVec3e$2);}/**
|
|
6402
6403
|
* Pans the Camera along its local X, Y and Z axis.
|
|
6403
6404
|
*
|
|
6404
6405
|
* @param pan The pan vector
|
|
6405
|
-
*/},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$
|
|
6406
|
+
*/},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$z));v=math.mulVec3Scalar(left,_pan[0]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[1]!==0){v=math.mulVec3Scalar(math.normalizeVec3(this._up,tempVec3c$u),_pan[1]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[2]!==0){v=math.mulVec3Scalar(math.normalizeVec3(eye2,tempVec3d$d),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$2);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
|
|
6406
6407
|
* Increments/decrements the Camera's zoom factor, which is the distance between {@link Camera#eye} and {@link Camera#look}.
|
|
6407
6408
|
*
|
|
6408
6409
|
* @param {Number} delta Zoom factor increment.
|
|
6409
|
-
*/},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$
|
|
6410
|
+
*/},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$z));var newLenLook=Math.abs(lenLook+delta);if(newLenLook<0.5){return;}var dir=math.normalizeVec3(vec,tempVec3c$u);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$d);}/**
|
|
6410
6411
|
* Sets the position of the Camera's eye.
|
|
6411
6412
|
*
|
|
6412
6413
|
* Default value is ````[0,0,10]````.
|
|
@@ -6628,7 +6629,7 @@ this.fire("dirty");this.fire("projection",this._projectionType);this.fire("projM
|
|
|
6628
6629
|
*
|
|
6629
6630
|
* @param {[number, number, number]} worldPos
|
|
6630
6631
|
* @returns {[number, number]} the canvas position
|
|
6631
|
-
*/},{key:"projectWorldPos",value:function projectWorldPos(worldPos){var _worldPos=tempVec4a$
|
|
6632
|
+
*/},{key:"projectWorldPos",value:function projectWorldPos(worldPos){var _worldPos=tempVec4a$b;var viewPos=tempVec4b$6;var screenPos=tempVec4c$2;_worldPos[0]=worldPos[0];_worldPos[1]=worldPos[1];_worldPos[2]=worldPos[2];_worldPos[3]=1;math.mulMat4v4(this.viewMatrix,_worldPos,viewPos);math.mulMat4v4(this.projMatrix,viewPos,screenPos);math.mulVec3Scalar(screenPos,1.0/screenPos[3]);screenPos[3]=1.0;screenPos[1]*=-1;var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;var canvasPos=[screenPos[0]*halfCanvasWidth+halfCanvasWidth,screenPos[1]*halfCanvasHeight+halfCanvasHeight];return canvasPos;}/**
|
|
6632
6633
|
* Destroys this Camera.
|
|
6633
6634
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(Camera.prototype),"destroy",this).call(this);this._state.destroy();}}]);return Camera;}(Component);/**
|
|
6634
6635
|
* @desc A dynamic light source within a {@link Scene}.
|
|
@@ -6738,7 +6739,7 @@ this.fire("dirty");this.fire("projection",this._projectionType);this.fire("projM
|
|
|
6738
6739
|
* @param {Number} [cfg.intensity=1.0] The intensity of this DirLight, as a factor in range ````[0..1]````.
|
|
6739
6740
|
* @param {String} [cfg.space="view"] The coordinate system the DirLight is defined in - ````"view"```` or ````"space"````.
|
|
6740
6741
|
* @param {Boolean} [cfg.castsShadow=false] Flag which indicates if this DirLight casts a castsShadow.
|
|
6741
|
-
*/function DirLight(owner){var _this48;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DirLight);_this48=_super26.call(this,owner,cfg);_this48._shadowRenderBuf=null;_this48._shadowViewMatrix=null;_this48._shadowProjMatrix=null;_this48._shadowViewMatrixDirty=true;_this48._shadowProjMatrixDirty=true;var camera=_this48.scene.camera;var canvas=_this48.scene.canvas;_this48._onCameraViewMatrix=camera.on("viewMatrix",function(){_this48._shadowViewMatrixDirty=true;});_this48._onCameraProjMatrix=camera.on("projMatrix",function(){_this48._shadowProjMatrixDirty=true;});_this48._onCanvasBoundary=canvas.on("boundary",function(){_this48._shadowProjMatrixDirty=true;});_this48._state=new RenderState({type:"dir",dir:math.vec3([1.0,1.0,1.0]),color:math.vec3([0.7,0.7,0.8]),intensity:1.0,space:cfg.space||"view",castsShadow:false,getShadowViewMatrix:function getShadowViewMatrix(){if(_this48._shadowViewMatrixDirty){if(!_this48._shadowViewMatrix){_this48._shadowViewMatrix=math.identityMat4();}var _camera=_this48.scene.camera;var dir=_this48._state.dir;var look=_camera.look;var eye=[look[0]-dir[0],look[1]-dir[1],look[2]-dir[2]];var
|
|
6742
|
+
*/function DirLight(owner){var _this48;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DirLight);_this48=_super26.call(this,owner,cfg);_this48._shadowRenderBuf=null;_this48._shadowViewMatrix=null;_this48._shadowProjMatrix=null;_this48._shadowViewMatrixDirty=true;_this48._shadowProjMatrixDirty=true;var camera=_this48.scene.camera;var canvas=_this48.scene.canvas;_this48._onCameraViewMatrix=camera.on("viewMatrix",function(){_this48._shadowViewMatrixDirty=true;});_this48._onCameraProjMatrix=camera.on("projMatrix",function(){_this48._shadowProjMatrixDirty=true;});_this48._onCanvasBoundary=canvas.on("boundary",function(){_this48._shadowProjMatrixDirty=true;});_this48._state=new RenderState({type:"dir",dir:math.vec3([1.0,1.0,1.0]),color:math.vec3([0.7,0.7,0.8]),intensity:1.0,space:cfg.space||"view",castsShadow:false,getShadowViewMatrix:function getShadowViewMatrix(){if(_this48._shadowViewMatrixDirty){if(!_this48._shadowViewMatrix){_this48._shadowViewMatrix=math.identityMat4();}var _camera=_this48.scene.camera;var dir=_this48._state.dir;var look=_camera.look;var eye=[look[0]-dir[0],look[1]-dir[1],look[2]-dir[2]];var _up=[0,1,0];math.lookAtMat4v(eye,look,_up,_this48._shadowViewMatrix);_this48._shadowViewMatrixDirty=false;}return _this48._shadowViewMatrix;},getShadowProjMatrix:function getShadowProjMatrix(){if(_this48._shadowProjMatrixDirty){// TODO: Set when canvas resizes
|
|
6742
6743
|
if(!_this48._shadowProjMatrix){_this48._shadowProjMatrix=math.identityMat4();}math.orthoMat4c(-40,40,-40,40,-40.0,80,_this48._shadowProjMatrix);// left, right, bottom, top, near, far, dest
|
|
6743
6744
|
_this48._shadowProjMatrixDirty=false;}return _this48._shadowProjMatrix;},getShadowRenderBuf:function getShadowRenderBuf(){if(!_this48._shadowRenderBuf){_this48._shadowRenderBuf=new RenderBuffer(_this48.scene.canvas.canvas,_this48.scene.canvas.gl,{size:[1024,1024]});// Super old mobile devices have a limit of 1024x1024 textures
|
|
6744
6745
|
}return _this48._shadowRenderBuf;}});_this48.dir=cfg.dir;_this48.color=cfg.color;_this48.intensity=cfg.intensity;_this48.castsShadow=cfg.castsShadow;_this48.scene._lightCreated(_assertThisInitialized(_this48));return _this48;}/**
|
|
@@ -10340,9 +10341,9 @@ if(phongMaterial){src.push("vec3 outgoingLight = (lightAmbient.rgb * lightAmbien
|
|
|
10340
10341
|
//--------------------------------------------------------------------------------
|
|
10341
10342
|
src.push("ambientColor *= (lightAmbient.rgb * lightAmbient.a);");src.push("vec3 outgoingLight = emissiveColor + ambientColor;");}src.push("vec4 fragColor = vec4(outgoingLight, alpha) * colorize;");if(gammaOutput){src.push("fragColor = linearToGamma(fragColor, gammaFactor);");}src.push("outColor = fragColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}/**
|
|
10342
10343
|
* @author xeolabs / https://github.com/xeolabs
|
|
10343
|
-
*/var tempVec3a$
|
|
10344
|
+
*/var tempVec3a$J=math.vec3();var ids$2=new Map$1({});/**
|
|
10344
10345
|
* @private
|
|
10345
|
-
*/var DrawRenderer=function DrawRenderer(hash,mesh){this.id=ids$2.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new DrawShaderSource(mesh);this._allocate(mesh);};var drawRenderers={};DrawRenderer.get=function(mesh){var scene=mesh.scene;var hash=[scene.canvas.canvas.id,(scene.gammaInput?"gi;":";")+(scene.gammaOutput?"go":""),scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._material._state.hash,mesh._state.drawHash].join(";");var renderer=drawRenderers[hash];if(!renderer){renderer=new DrawRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}drawRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};DrawRenderer.prototype.put=function(){if(--this._useCount===0){ids$2.removeItem(this.id);if(this._program){this._program.destroy();}delete drawRenderers[this._hash];stats.memory.programs--;}};DrawRenderer.prototype.webglContextRestored=function(){this._program=null;};DrawRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=mesh.scene;var material=mesh._material;var gl=scene.canvas.gl;var program=this._program;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var camera=scene.camera;var origin=mesh.origin;var background=meshState.background;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;if(background){gl.depthFunc(gl.LEQUAL);}this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$I);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){frameCtx.textureUnit=this._baseTextureUnit;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}if(frameCtx.lineWidth!==materialState.lineWidth){gl.lineWidth(materialState.lineWidth);frameCtx.lineWidth=materialState.lineWidth;}if(this._uPointSize){gl.uniform1f(this._uPointSize,materialState.pointSize);}switch(materialState.type){case"LambertMaterial":if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialColor){gl.uniform4f(this._uMaterialColor,materialState.color[0],materialState.color[1],materialState.color[2],materialState.alpha);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}break;case"PhongMaterial":if(this._uMaterialShininess){gl.uniform1f(this._uMaterialShininess,materialState.shininess);}if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0);}if(material._ambientMap&&material._ambientMap._state.texture&&this._uMaterialAmbientMap){program.bindTexture(this._uMaterialAmbientMap,material._ambientMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMaterialAmbientMapMatrix){gl.uniformMatrix4fv(this._uMaterialAmbientMapMatrix,false,material._ambientMap._state.matrix);}}if(material._diffuseMap&&material._diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,material._diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,material._diffuseMap._state.matrix);}}if(material._specularMap&&material._specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,material._specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,material._specularMap._state.matrix);}}if(material._emissiveMap&&material._emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,material._emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,material._emissiveMap._state.matrix);}}if(material._alphaMap&&material._alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,material._alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,material._alphaMap._state.matrix);}}if(material._reflectivityMap&&material._reflectivityMap._state.texture&&this._uReflectivityMap){program.bindTexture(this._uReflectivityMap,material._reflectivityMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;if(this._uReflectivityMapMatrix){gl.uniformMatrix4fv(this._uReflectivityMapMatrix,false,material._reflectivityMap._state.matrix);}}if(material._normalMap&&material._normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,material._normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,material._normalMap._state.matrix);}}if(material._occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,material._occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,material._occlusionMap._state.matrix);}}if(material._diffuseFresnel){if(this._uDiffuseFresnelEdgeBias){gl.uniform1f(this._uDiffuseFresnelEdgeBias,material._diffuseFresnel.edgeBias);}if(this._uDiffuseFresnelCenterBias){gl.uniform1f(this._uDiffuseFresnelCenterBias,material._diffuseFresnel.centerBias);}if(this._uDiffuseFresnelEdgeColor){gl.uniform3fv(this._uDiffuseFresnelEdgeColor,material._diffuseFresnel.edgeColor);}if(this._uDiffuseFresnelCenterColor){gl.uniform3fv(this._uDiffuseFresnelCenterColor,material._diffuseFresnel.centerColor);}if(this._uDiffuseFresnelPower){gl.uniform1f(this._uDiffuseFresnelPower,material._diffuseFresnel.power);}}if(material._specularFresnel){if(this._uSpecularFresnelEdgeBias){gl.uniform1f(this._uSpecularFresnelEdgeBias,material._specularFresnel.edgeBias);}if(this._uSpecularFresnelCenterBias){gl.uniform1f(this._uSpecularFresnelCenterBias,material._specularFresnel.centerBias);}if(this._uSpecularFresnelEdgeColor){gl.uniform3fv(this._uSpecularFresnelEdgeColor,material._specularFresnel.edgeColor);}if(this._uSpecularFresnelCenterColor){gl.uniform3fv(this._uSpecularFresnelCenterColor,material._specularFresnel.centerColor);}if(this._uSpecularFresnelPower){gl.uniform1f(this._uSpecularFresnelPower,material._specularFresnel.power);}}if(material._alphaFresnel){if(this._uAlphaFresnelEdgeBias){gl.uniform1f(this._uAlphaFresnelEdgeBias,material._alphaFresnel.edgeBias);}if(this._uAlphaFresnelCenterBias){gl.uniform1f(this._uAlphaFresnelCenterBias,material._alphaFresnel.centerBias);}if(this._uAlphaFresnelEdgeColor){gl.uniform3fv(this._uAlphaFresnelEdgeColor,material._alphaFresnel.edgeColor);}if(this._uAlphaFresnelCenterColor){gl.uniform3fv(this._uAlphaFresnelCenterColor,material._alphaFresnel.centerColor);}if(this._uAlphaFresnelPower){gl.uniform1f(this._uAlphaFresnelPower,material._alphaFresnel.power);}}if(material._reflectivityFresnel){if(this._uReflectivityFresnelEdgeBias){gl.uniform1f(this._uReflectivityFresnelEdgeBias,material._reflectivityFresnel.edgeBias);}if(this._uReflectivityFresnelCenterBias){gl.uniform1f(this._uReflectivityFresnelCenterBias,material._reflectivityFresnel.centerBias);}if(this._uReflectivityFresnelEdgeColor){gl.uniform3fv(this._uReflectivityFresnelEdgeColor,material._reflectivityFresnel.edgeColor);}if(this._uReflectivityFresnelCenterColor){gl.uniform3fv(this._uReflectivityFresnelCenterColor,material._reflectivityFresnel.centerColor);}if(this._uReflectivityFresnelPower){gl.uniform1f(this._uReflectivityFresnelPower,material._reflectivityFresnel.power);}}if(material._emissiveFresnel){if(this._uEmissiveFresnelEdgeBias){gl.uniform1f(this._uEmissiveFresnelEdgeBias,material._emissiveFresnel.edgeBias);}if(this._uEmissiveFresnelCenterBias){gl.uniform1f(this._uEmissiveFresnelCenterBias,material._emissiveFresnel.centerBias);}if(this._uEmissiveFresnelEdgeColor){gl.uniform3fv(this._uEmissiveFresnelEdgeColor,material._emissiveFresnel.edgeColor);}if(this._uEmissiveFresnelCenterColor){gl.uniform3fv(this._uEmissiveFresnelCenterColor,material._emissiveFresnel.centerColor);}if(this._uEmissiveFresnelPower){gl.uniform1f(this._uEmissiveFresnelPower,material._emissiveFresnel.power);}}break;case"MetallicMaterial":if(this._uBaseColor){gl.uniform3fv(this._uBaseColor,materialState.baseColor);}if(this._uMaterialMetallic){gl.uniform1f(this._uMaterialMetallic,materialState.metallic);}if(this._uMaterialRoughness){gl.uniform1f(this._uMaterialRoughness,materialState.roughness);}if(this._uMaterialSpecularF0){gl.uniform1f(this._uMaterialSpecularF0,materialState.specularF0);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var baseColorMap=material._baseColorMap;if(baseColorMap&&baseColorMap._state.texture&&this._uBaseColorMap){program.bindTexture(this._uBaseColorMap,baseColorMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uBaseColorMapMatrix){gl.uniformMatrix4fv(this._uBaseColorMapMatrix,false,baseColorMap._state.matrix);}}var metallicMap=material._metallicMap;if(metallicMap&&metallicMap._state.texture&&this._uMetallicMap){program.bindTexture(this._uMetallicMap,metallicMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicMapMatrix){gl.uniformMatrix4fv(this._uMetallicMapMatrix,false,metallicMap._state.matrix);}}var roughnessMap=material._roughnessMap;if(roughnessMap&&roughnessMap._state.texture&&this._uRoughnessMap){program.bindTexture(this._uRoughnessMap,roughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uRoughnessMapMatrix){gl.uniformMatrix4fv(this._uRoughnessMapMatrix,false,roughnessMap._state.matrix);}}var metallicRoughnessMap=material._metallicRoughnessMap;if(metallicRoughnessMap&&metallicRoughnessMap._state.texture&&this._uMetallicRoughnessMap){program.bindTexture(this._uMetallicRoughnessMap,metallicRoughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicRoughnessMapMatrix){gl.uniformMatrix4fv(this._uMetallicRoughnessMapMatrix,false,metallicRoughnessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;case"SpecularMaterial":if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialGlossiness){gl.uniform1f(this._uMaterialGlossiness,materialState.glossiness);}if(this._uMaterialReflectivity){gl.uniform1f(this._uMaterialReflectivity,materialState.reflectivity);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var diffuseMap=material._diffuseMap;if(diffuseMap&&diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,diffuseMap._state.matrix);}}var specularMap=material._specularMap;if(specularMap&&specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,specularMap._state.matrix);}}var glossinessMap=material._glossinessMap;if(glossinessMap&&glossinessMap._state.texture&&this._uGlossinessMap){program.bindTexture(this._uGlossinessMap,glossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uGlossinessMapMatrix){gl.uniformMatrix4fv(this._uGlossinessMapMatrix,false,glossinessMap._state.matrix);}}var specularGlossinessMap=material._specularGlossinessMap;if(specularGlossinessMap&&specularGlossinessMap._state.texture&&this._uSpecularGlossinessMap){program.bindTexture(this._uSpecularGlossinessMap,specularGlossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularGlossinessMapMatrix){gl.uniformMatrix4fv(this._uSpecularGlossinessMapMatrix,false,specularGlossinessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}if(this._uColorize){var colorize=meshState.colorize;var lastColorize=this._lastColorize;if(lastColorize[0]!==colorize[0]||lastColorize[1]!==colorize[1]||lastColorize[2]!==colorize[2]||lastColorize[3]!==colorize[3]){gl.uniform4fv(this._uColorize,colorize);lastColorize[0]=colorize[0];lastColorize[1]=colorize[1];lastColorize[2]=colorize[2];lastColorize[3]=colorize[3];}}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
|
|
10346
|
+
*/var DrawRenderer=function DrawRenderer(hash,mesh){this.id=ids$2.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new DrawShaderSource(mesh);this._allocate(mesh);};var drawRenderers={};DrawRenderer.get=function(mesh){var scene=mesh.scene;var hash=[scene.canvas.canvas.id,(scene.gammaInput?"gi;":";")+(scene.gammaOutput?"go":""),scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._material._state.hash,mesh._state.drawHash].join(";");var renderer=drawRenderers[hash];if(!renderer){renderer=new DrawRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}drawRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};DrawRenderer.prototype.put=function(){if(--this._useCount===0){ids$2.removeItem(this.id);if(this._program){this._program.destroy();}delete drawRenderers[this._hash];stats.memory.programs--;}};DrawRenderer.prototype.webglContextRestored=function(){this._program=null;};DrawRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=mesh.scene;var material=mesh._material;var gl=scene.canvas.gl;var program=this._program;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var camera=scene.camera;var origin=mesh.origin;var background=meshState.background;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;if(background){gl.depthFunc(gl.LEQUAL);}this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$J);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){frameCtx.textureUnit=this._baseTextureUnit;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}if(frameCtx.lineWidth!==materialState.lineWidth){gl.lineWidth(materialState.lineWidth);frameCtx.lineWidth=materialState.lineWidth;}if(this._uPointSize){gl.uniform1f(this._uPointSize,materialState.pointSize);}switch(materialState.type){case"LambertMaterial":if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialColor){gl.uniform4f(this._uMaterialColor,materialState.color[0],materialState.color[1],materialState.color[2],materialState.alpha);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}break;case"PhongMaterial":if(this._uMaterialShininess){gl.uniform1f(this._uMaterialShininess,materialState.shininess);}if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0);}if(material._ambientMap&&material._ambientMap._state.texture&&this._uMaterialAmbientMap){program.bindTexture(this._uMaterialAmbientMap,material._ambientMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMaterialAmbientMapMatrix){gl.uniformMatrix4fv(this._uMaterialAmbientMapMatrix,false,material._ambientMap._state.matrix);}}if(material._diffuseMap&&material._diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,material._diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,material._diffuseMap._state.matrix);}}if(material._specularMap&&material._specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,material._specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,material._specularMap._state.matrix);}}if(material._emissiveMap&&material._emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,material._emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,material._emissiveMap._state.matrix);}}if(material._alphaMap&&material._alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,material._alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,material._alphaMap._state.matrix);}}if(material._reflectivityMap&&material._reflectivityMap._state.texture&&this._uReflectivityMap){program.bindTexture(this._uReflectivityMap,material._reflectivityMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;if(this._uReflectivityMapMatrix){gl.uniformMatrix4fv(this._uReflectivityMapMatrix,false,material._reflectivityMap._state.matrix);}}if(material._normalMap&&material._normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,material._normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,material._normalMap._state.matrix);}}if(material._occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,material._occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,material._occlusionMap._state.matrix);}}if(material._diffuseFresnel){if(this._uDiffuseFresnelEdgeBias){gl.uniform1f(this._uDiffuseFresnelEdgeBias,material._diffuseFresnel.edgeBias);}if(this._uDiffuseFresnelCenterBias){gl.uniform1f(this._uDiffuseFresnelCenterBias,material._diffuseFresnel.centerBias);}if(this._uDiffuseFresnelEdgeColor){gl.uniform3fv(this._uDiffuseFresnelEdgeColor,material._diffuseFresnel.edgeColor);}if(this._uDiffuseFresnelCenterColor){gl.uniform3fv(this._uDiffuseFresnelCenterColor,material._diffuseFresnel.centerColor);}if(this._uDiffuseFresnelPower){gl.uniform1f(this._uDiffuseFresnelPower,material._diffuseFresnel.power);}}if(material._specularFresnel){if(this._uSpecularFresnelEdgeBias){gl.uniform1f(this._uSpecularFresnelEdgeBias,material._specularFresnel.edgeBias);}if(this._uSpecularFresnelCenterBias){gl.uniform1f(this._uSpecularFresnelCenterBias,material._specularFresnel.centerBias);}if(this._uSpecularFresnelEdgeColor){gl.uniform3fv(this._uSpecularFresnelEdgeColor,material._specularFresnel.edgeColor);}if(this._uSpecularFresnelCenterColor){gl.uniform3fv(this._uSpecularFresnelCenterColor,material._specularFresnel.centerColor);}if(this._uSpecularFresnelPower){gl.uniform1f(this._uSpecularFresnelPower,material._specularFresnel.power);}}if(material._alphaFresnel){if(this._uAlphaFresnelEdgeBias){gl.uniform1f(this._uAlphaFresnelEdgeBias,material._alphaFresnel.edgeBias);}if(this._uAlphaFresnelCenterBias){gl.uniform1f(this._uAlphaFresnelCenterBias,material._alphaFresnel.centerBias);}if(this._uAlphaFresnelEdgeColor){gl.uniform3fv(this._uAlphaFresnelEdgeColor,material._alphaFresnel.edgeColor);}if(this._uAlphaFresnelCenterColor){gl.uniform3fv(this._uAlphaFresnelCenterColor,material._alphaFresnel.centerColor);}if(this._uAlphaFresnelPower){gl.uniform1f(this._uAlphaFresnelPower,material._alphaFresnel.power);}}if(material._reflectivityFresnel){if(this._uReflectivityFresnelEdgeBias){gl.uniform1f(this._uReflectivityFresnelEdgeBias,material._reflectivityFresnel.edgeBias);}if(this._uReflectivityFresnelCenterBias){gl.uniform1f(this._uReflectivityFresnelCenterBias,material._reflectivityFresnel.centerBias);}if(this._uReflectivityFresnelEdgeColor){gl.uniform3fv(this._uReflectivityFresnelEdgeColor,material._reflectivityFresnel.edgeColor);}if(this._uReflectivityFresnelCenterColor){gl.uniform3fv(this._uReflectivityFresnelCenterColor,material._reflectivityFresnel.centerColor);}if(this._uReflectivityFresnelPower){gl.uniform1f(this._uReflectivityFresnelPower,material._reflectivityFresnel.power);}}if(material._emissiveFresnel){if(this._uEmissiveFresnelEdgeBias){gl.uniform1f(this._uEmissiveFresnelEdgeBias,material._emissiveFresnel.edgeBias);}if(this._uEmissiveFresnelCenterBias){gl.uniform1f(this._uEmissiveFresnelCenterBias,material._emissiveFresnel.centerBias);}if(this._uEmissiveFresnelEdgeColor){gl.uniform3fv(this._uEmissiveFresnelEdgeColor,material._emissiveFresnel.edgeColor);}if(this._uEmissiveFresnelCenterColor){gl.uniform3fv(this._uEmissiveFresnelCenterColor,material._emissiveFresnel.centerColor);}if(this._uEmissiveFresnelPower){gl.uniform1f(this._uEmissiveFresnelPower,material._emissiveFresnel.power);}}break;case"MetallicMaterial":if(this._uBaseColor){gl.uniform3fv(this._uBaseColor,materialState.baseColor);}if(this._uMaterialMetallic){gl.uniform1f(this._uMaterialMetallic,materialState.metallic);}if(this._uMaterialRoughness){gl.uniform1f(this._uMaterialRoughness,materialState.roughness);}if(this._uMaterialSpecularF0){gl.uniform1f(this._uMaterialSpecularF0,materialState.specularF0);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var baseColorMap=material._baseColorMap;if(baseColorMap&&baseColorMap._state.texture&&this._uBaseColorMap){program.bindTexture(this._uBaseColorMap,baseColorMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uBaseColorMapMatrix){gl.uniformMatrix4fv(this._uBaseColorMapMatrix,false,baseColorMap._state.matrix);}}var metallicMap=material._metallicMap;if(metallicMap&&metallicMap._state.texture&&this._uMetallicMap){program.bindTexture(this._uMetallicMap,metallicMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicMapMatrix){gl.uniformMatrix4fv(this._uMetallicMapMatrix,false,metallicMap._state.matrix);}}var roughnessMap=material._roughnessMap;if(roughnessMap&&roughnessMap._state.texture&&this._uRoughnessMap){program.bindTexture(this._uRoughnessMap,roughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uRoughnessMapMatrix){gl.uniformMatrix4fv(this._uRoughnessMapMatrix,false,roughnessMap._state.matrix);}}var metallicRoughnessMap=material._metallicRoughnessMap;if(metallicRoughnessMap&&metallicRoughnessMap._state.texture&&this._uMetallicRoughnessMap){program.bindTexture(this._uMetallicRoughnessMap,metallicRoughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicRoughnessMapMatrix){gl.uniformMatrix4fv(this._uMetallicRoughnessMapMatrix,false,metallicRoughnessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;case"SpecularMaterial":if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialGlossiness){gl.uniform1f(this._uMaterialGlossiness,materialState.glossiness);}if(this._uMaterialReflectivity){gl.uniform1f(this._uMaterialReflectivity,materialState.reflectivity);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var diffuseMap=material._diffuseMap;if(diffuseMap&&diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,diffuseMap._state.matrix);}}var specularMap=material._specularMap;if(specularMap&&specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,specularMap._state.matrix);}}var glossinessMap=material._glossinessMap;if(glossinessMap&&glossinessMap._state.texture&&this._uGlossinessMap){program.bindTexture(this._uGlossinessMap,glossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uGlossinessMapMatrix){gl.uniformMatrix4fv(this._uGlossinessMapMatrix,false,glossinessMap._state.matrix);}}var specularGlossinessMap=material._specularGlossinessMap;if(specularGlossinessMap&&specularGlossinessMap._state.texture&&this._uSpecularGlossinessMap){program.bindTexture(this._uSpecularGlossinessMap,specularGlossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularGlossinessMapMatrix){gl.uniformMatrix4fv(this._uSpecularGlossinessMapMatrix,false,specularGlossinessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}if(this._uColorize){var colorize=meshState.colorize;var lastColorize=this._lastColorize;if(lastColorize[0]!==colorize[0]||lastColorize[1]!==colorize[1]||lastColorize[2]!==colorize[2]||lastColorize[3]!==colorize[3]){gl.uniform4fv(this._uColorize,colorize);lastColorize[0]=colorize[0];lastColorize[1]=colorize[1];lastColorize[2]=colorize[2];lastColorize[3]=colorize[3];}}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
|
|
10346
10347
|
if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometryState.uvDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf);frameCtx.bindArray++;}if(this._aNormal){this._aNormal.bindArrayBuffer(geometryState.normalsBuf);frameCtx.bindArray++;}if(this._aUV){this._aUV.bindArrayBuffer(geometryState.uvBuf);frameCtx.bindArray++;}if(this._aColor){this._aColor.bindArrayBuffer(geometryState.colorsBuf);frameCtx.bindArray++;}if(this._aFlags){this._aFlags.bindArrayBuffer(geometryState.flagsBuf);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}// Draw (indices bound in prev step)
|
|
10347
10348
|
if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);frameCtx.drawArrays++;}if(background){gl.depthFunc(gl.LESS);}};DrawRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;var material=mesh._material;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var materialState=mesh._material._state;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uModelNormalMatrix=program.getLocation("modelNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uGammaFactor=program.getLocation("gammaFactor");this._uLightAmbient=[];this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];this._uShadowViewMatrix=[];this._uShadowProjMatrix=[];if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}var lights=lightsState.lights;var light;for(var i=0,len=lights.length;i<len;i++){light=lights[i];switch(light.type){case"ambient":this._uLightAmbient[i]=program.getLocation("lightAmbient");break;case"dir":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=null;this._uLightDir[i]=program.getLocation("lightDir"+i);break;case"point":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=program.getLocation("lightPos"+i);this._uLightDir[i]=null;this._uLightAttenuation[i]=program.getLocation("lightAttenuation"+i);break;case"spot":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=program.getLocation("lightPos"+i);this._uLightDir[i]=program.getLocation("lightDir"+i);this._uLightAttenuation[i]=program.getLocation("lightAttenuation"+i);break;}if(light.castsShadow){this._uShadowViewMatrix[i]=program.getLocation("shadowViewMatrix"+i);this._uShadowProjMatrix[i]=program.getLocation("shadowProjMatrix"+i);}}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}this._uSectionPlanes=[];var sectionPlanes=sectionPlanesState.sectionPlanes;for(var i=0,len=sectionPlanes.length;i<len;i++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+i),pos:program.getLocation("sectionPlanePos"+i),dir:program.getLocation("sectionPlaneDir"+i)});}this._uPointSize=program.getLocation("pointSize");switch(materialState.type){case"LambertMaterial":this._uMaterialColor=program.getLocation("materialColor");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");break;case"PhongMaterial":this._uMaterialAmbient=program.getLocation("materialAmbient");this._uMaterialDiffuse=program.getLocation("materialDiffuse");this._uMaterialSpecular=program.getLocation("materialSpecular");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");this._uMaterialShininess=program.getLocation("materialShininess");if(material._ambientMap){this._uMaterialAmbientMap="ambientMap";this._uMaterialAmbientMapMatrix=program.getLocation("ambientMapMatrix");}if(material._diffuseMap){this._uDiffuseMap="diffuseMap";this._uDiffuseMapMatrix=program.getLocation("diffuseMapMatrix");}if(material._specularMap){this._uSpecularMap="specularMap";this._uSpecularMapMatrix=program.getLocation("specularMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._reflectivityMap){this._uReflectivityMap="reflectivityMap";this._uReflectivityMapMatrix=program.getLocation("reflectivityMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._diffuseFresnel){this._uDiffuseFresnelEdgeBias=program.getLocation("diffuseFresnelEdgeBias");this._uDiffuseFresnelCenterBias=program.getLocation("diffuseFresnelCenterBias");this._uDiffuseFresnelEdgeColor=program.getLocation("diffuseFresnelEdgeColor");this._uDiffuseFresnelCenterColor=program.getLocation("diffuseFresnelCenterColor");this._uDiffuseFresnelPower=program.getLocation("diffuseFresnelPower");}if(material._specularFresnel){this._uSpecularFresnelEdgeBias=program.getLocation("specularFresnelEdgeBias");this._uSpecularFresnelCenterBias=program.getLocation("specularFresnelCenterBias");this._uSpecularFresnelEdgeColor=program.getLocation("specularFresnelEdgeColor");this._uSpecularFresnelCenterColor=program.getLocation("specularFresnelCenterColor");this._uSpecularFresnelPower=program.getLocation("specularFresnelPower");}if(material._alphaFresnel){this._uAlphaFresnelEdgeBias=program.getLocation("alphaFresnelEdgeBias");this._uAlphaFresnelCenterBias=program.getLocation("alphaFresnelCenterBias");this._uAlphaFresnelEdgeColor=program.getLocation("alphaFresnelEdgeColor");this._uAlphaFresnelCenterColor=program.getLocation("alphaFresnelCenterColor");this._uAlphaFresnelPower=program.getLocation("alphaFresnelPower");}if(material._reflectivityFresnel){this._uReflectivityFresnelEdgeBias=program.getLocation("reflectivityFresnelEdgeBias");this._uReflectivityFresnelCenterBias=program.getLocation("reflectivityFresnelCenterBias");this._uReflectivityFresnelEdgeColor=program.getLocation("reflectivityFresnelEdgeColor");this._uReflectivityFresnelCenterColor=program.getLocation("reflectivityFresnelCenterColor");this._uReflectivityFresnelPower=program.getLocation("reflectivityFresnelPower");}if(material._emissiveFresnel){this._uEmissiveFresnelEdgeBias=program.getLocation("emissiveFresnelEdgeBias");this._uEmissiveFresnelCenterBias=program.getLocation("emissiveFresnelCenterBias");this._uEmissiveFresnelEdgeColor=program.getLocation("emissiveFresnelEdgeColor");this._uEmissiveFresnelCenterColor=program.getLocation("emissiveFresnelCenterColor");this._uEmissiveFresnelPower=program.getLocation("emissiveFresnelPower");}break;case"MetallicMaterial":this._uBaseColor=program.getLocation("materialBaseColor");this._uMaterialMetallic=program.getLocation("materialMetallic");this._uMaterialRoughness=program.getLocation("materialRoughness");this._uMaterialSpecularF0=program.getLocation("materialSpecularF0");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");if(material._baseColorMap){this._uBaseColorMap="baseColorMap";this._uBaseColorMapMatrix=program.getLocation("baseColorMapMatrix");}if(material._metallicMap){this._uMetallicMap="metallicMap";this._uMetallicMapMatrix=program.getLocation("metallicMapMatrix");}if(material._roughnessMap){this._uRoughnessMap="roughnessMap";this._uRoughnessMapMatrix=program.getLocation("roughnessMapMatrix");}if(material._metallicRoughnessMap){this._uMetallicRoughnessMap="metallicRoughnessMap";this._uMetallicRoughnessMapMatrix=program.getLocation("metallicRoughnessMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}break;case"SpecularMaterial":this._uMaterialDiffuse=program.getLocation("materialDiffuse");this._uMaterialSpecular=program.getLocation("materialSpecular");this._uMaterialGlossiness=program.getLocation("materialGlossiness");this._uMaterialReflectivity=program.getLocation("reflectivityFresnel");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");if(material._diffuseMap){this._uDiffuseMap="diffuseMap";this._uDiffuseMapMatrix=program.getLocation("diffuseMapMatrix");}if(material._specularMap){this._uSpecularMap="specularMap";this._uSpecularMapMatrix=program.getLocation("specularMapMatrix");}if(material._glossinessMap){this._uGlossinessMap="glossinessMap";this._uGlossinessMapMatrix=program.getLocation("glossinessMapMatrix");}if(material._specularGlossinessMap){this._uSpecularGlossinessMap="materialSpecularGlossinessMap";this._uSpecularGlossinessMapMatrix=program.getLocation("materialSpecularGlossinessMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}break;}this._aPosition=program.getAttribute("position");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");this._uClippable=program.getLocation("clippable");this._uColorize=program.getLocation("colorize");this._uOffset=program.getLocation("offset");this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastColorize=new Float32Array(4);this._baseTextureUnit=0;};DrawRenderer.prototype._bindProgram=function(frameCtx){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var project=scene.camera.project;var light;var program=this._program;program.bind();frameCtx.useProgram++;frameCtx.textureUnit=0;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastColorize[0]=-1;this._lastColorize[1]=-1;this._lastColorize[2]=-1;this._lastColorize[3]=-1;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(this._uLightAmbient[i]){gl.uniform4f(this._uLightAmbient[i],light.color[0],light.color[1],light.color[2],light.intensity);}else{if(this._uLightColor[i]){gl.uniform4f(this._uLightColor[i],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[i]){gl.uniform3fv(this._uLightPos[i],light.pos);if(this._uLightAttenuation[i]){gl.uniform1f(this._uLightAttenuation[i],light.attenuation);}}if(this._uLightDir[i]){gl.uniform3fv(this._uLightDir[i],light.dir);}if(light.castsShadow){if(this._uShadowViewMatrix[i]){gl.uniformMatrix4fv(this._uShadowViewMatrix[i],false,light.getShadowViewMatrix());}if(this._uShadowProjMatrix[i]){gl.uniformMatrix4fv(this._uShadowProjMatrix[i],false,light.getShadowProjMatrix());}var shadowRenderBuf=light.getShadowRenderBuf();if(shadowRenderBuf){program.bindTexture("shadowMap"+i,shadowRenderBuf.getTexture(),frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}}}if(lightsState.lightMaps.length>0&&lightsState.lightMaps[0].texture&&this._uLightMap){program.bindTexture(this._uLightMap,lightsState.lightMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(lightsState.reflectionMaps.length>0&&lightsState.reflectionMaps[0].texture&&this._uReflectionMap){program.bindTexture(this._uReflectionMap,lightsState.reflectionMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}this._baseTextureUnit=frameCtx.textureUnit;};/**
|
|
10348
10349
|
* @private
|
|
@@ -10351,47 +10352,47 @@ if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometrySta
|
|
|
10351
10352
|
src.push("vColor = vec4(reflectedColor * fillColor.rgb, fillColor.a);");//src.push("vColor = vec4(reflectedColor + fillColor.rgb, fillColor.a);");
|
|
10352
10353
|
if(clipping){src.push("vWorldPosition = worldPosition;");}if(mesh._geometry._state.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");return src;}function hasNormals(mesh){var primitive=mesh._geometry._state.primitiveName;if((mesh._geometry._state.autoVertexNormals||mesh._geometry._state.normalsBuf)&&(primitive==="triangles"||primitive==="triangle-strip"||primitive==="triangle-fan")){return true;}return false;}function buildFragment$5(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Lambertian drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i112=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i112<len;_i112++){src.push("uniform bool sectionPlaneActive"+_i112+";");src.push("uniform vec3 sectionPlanePos"+_i112+";");src.push("uniform vec3 sectionPlaneDir"+_i112+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i113=0,_len16=sectionPlanesState.getNumAllocatedSectionPlanes();_i113<_len16;_i113++){src.push("if (sectionPlaneActive"+_i113+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i113+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i113+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(mesh._geometry._state.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
|
|
10353
10354
|
* @author xeolabs / https://github.com/xeolabs
|
|
10354
|
-
*/var ids$1=new Map$1({});var tempVec3a$
|
|
10355
|
+
*/var ids$1=new Map$1({});var tempVec3a$I=math.vec3();/**
|
|
10355
10356
|
* @private
|
|
10356
10357
|
*/var EmphasisFillRenderer=function EmphasisFillRenderer(hash,mesh){this.id=ids$1.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new EmphasisFillShaderSource(mesh);this._allocate(mesh);};var xrayFillRenderers={};EmphasisFillRenderer.get=function(mesh){var hash=[mesh.scene.id,mesh.scene.gammaOutput?"go":"",// Gamma input not needed
|
|
10357
|
-
mesh.scene._sectionPlanesState.getHash(),!!mesh._geometry._state.normalsBuf?"n":"",mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=xrayFillRenderers[hash];if(!renderer){renderer=new EmphasisFillRenderer(hash,mesh);xrayFillRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisFillRenderer.prototype.put=function(){if(--this._useCount===0){ids$1.removeItem(this.id);if(this._program){this._program.destroy();}delete xrayFillRenderers[this._hash];stats.memory.programs--;}};EmphasisFillRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisFillRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState=mode===0?mesh._xrayMaterial._state:mode===1?mesh._highlightMaterial._state:mesh._selectedMaterial._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
10358
|
+
mesh.scene._sectionPlanesState.getHash(),!!mesh._geometry._state.normalsBuf?"n":"",mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=xrayFillRenderers[hash];if(!renderer){renderer=new EmphasisFillRenderer(hash,mesh);xrayFillRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisFillRenderer.prototype.put=function(){if(--this._useCount===0){ids$1.removeItem(this.id);if(this._program){this._program.destroy();}delete xrayFillRenderers[this._hash];stats.memory.programs--;}};EmphasisFillRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisFillRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState=mode===0?mesh._xrayMaterial._state:mode===1?mesh._highlightMaterial._state:mesh._selectedMaterial._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$I);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){var fillColor=materialState.fillColor;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}gl.uniform4f(this._uFillColor,fillColor[0],fillColor[1],fillColor[2],materialState.fillAlpha);this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
|
|
10358
10359
|
if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometryState.uvDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf);frameCtx.bindArray++;}if(this._aNormal){this._aNormal.bindArrayBuffer(geometryState.normalsBuf);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;// gl.drawElements(geometryState.primitive, geometryState.indicesBuf.numItems, geometryState.indicesBuf.itemType, 0);
|
|
10359
10360
|
// frameCtx.drawElements++;
|
|
10360
10361
|
}else if(geometryState.positionsBuf);this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positionsBuf){gl.drawArrays(gl.TRIANGLES,0,geometryState.positionsBuf.numItems);frameCtx.drawArrays++;}};EmphasisFillRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uModelNormalMatrix=program.getLocation("modelNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uLightAmbient=[];this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];for(var _i114=0,len=lightsState.lights.length;_i114<len;_i114++){var light=lightsState.lights[_i114];switch(light.type){case"ambient":this._uLightAmbient[_i114]=program.getLocation("lightAmbient");break;case"dir":this._uLightColor[_i114]=program.getLocation("lightColor"+_i114);this._uLightPos[_i114]=null;this._uLightDir[_i114]=program.getLocation("lightDir"+_i114);break;case"point":this._uLightColor[_i114]=program.getLocation("lightColor"+_i114);this._uLightPos[_i114]=program.getLocation("lightPos"+_i114);this._uLightDir[_i114]=null;this._uLightAttenuation[_i114]=program.getLocation("lightAttenuation"+_i114);break;}}this._uSectionPlanes=[];for(var _i115=0,_len17=sectionPlanesState.getNumAllocatedSectionPlanes();_i115<_len17;_i115++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i115),pos:program.getLocation("sectionPlanePos"+_i115),dir:program.getLocation("sectionPlaneDir"+_i115)});}this._uFillColor=program.getLocation("fillColor");this._aPosition=program.getAttribute("position");this._aNormal=program.getAttribute("normal");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisFillRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var camera=scene.camera;var project=camera.project;var program=this._program;program.bind();frameCtx.useProgram++;frameCtx.textureUnit=0;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastIndicesBufId=null;gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.normalMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var _i116=0,len=lightsState.lights.length;_i116<len;_i116++){var light=lightsState.lights[_i116];if(this._uLightAmbient[_i116]){gl.uniform4f(this._uLightAmbient[_i116],light.color[0],light.color[1],light.color[2],light.intensity);}else{if(this._uLightColor[_i116]){gl.uniform4f(this._uLightColor[_i116],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i116]){gl.uniform3fv(this._uLightPos[_i116],light.pos);if(this._uLightAttenuation[_i116]){gl.uniform1f(this._uLightAttenuation[_i116],light.attenuation);}}if(this._uLightDir[_i116]){gl.uniform3fv(this._uLightDir[_i116],light.dir);}}}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
|
|
10361
10362
|
* @private
|
|
10362
10363
|
*/var EmphasisEdgesShaderSource=/*#__PURE__*/_createClass(function EmphasisEdgesShaderSource(mesh){_classCallCheck(this,EmphasisEdgesShaderSource);this.vertex=buildVertex$4(mesh);this.fragment=buildFragment$4(mesh);});function buildVertex$4(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push("#version 300 es");src.push("// Edges drawing vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 edgeColor;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("out vec4 vColor;");if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}src.push("vColor = edgeColor;");if(clipping){src.push("vWorldPosition = worldPosition;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");return src;}function buildFragment$4(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i117=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i117<len;_i117++){src.push("uniform bool sectionPlaneActive"+_i117+";");src.push("uniform vec3 sectionPlanePos"+_i117+";");src.push("uniform vec3 sectionPlaneDir"+_i117+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i118=0,_len18=sectionPlanesState.getNumAllocatedSectionPlanes();_i118<_len18;_i118++){src.push("if (sectionPlaneActive"+_i118+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i118+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i118+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
|
|
10363
10364
|
* @author xeolabs / https://github.com/xeolabs
|
|
10364
|
-
*/var ids=new Map$1({});var tempVec3a$
|
|
10365
|
+
*/var ids=new Map$1({});var tempVec3a$H=math.vec3();/**
|
|
10365
10366
|
* @private
|
|
10366
10367
|
*/var EmphasisEdgesRenderer=function EmphasisEdgesRenderer(hash,mesh){this.id=ids.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new EmphasisEdgesShaderSource(mesh);this._allocate(mesh);};var renderers$4={};EmphasisEdgesRenderer.get=function(mesh){var hash=[mesh.scene.id,mesh.scene.gammaOutput?"go":"",// Gamma input not needed
|
|
10367
|
-
mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$4[hash];if(!renderer){renderer=new EmphasisEdgesRenderer(hash,mesh);renderers$4[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisEdgesRenderer.prototype.put=function(){if(--this._useCount===0){ids.removeItem(this.id);if(this._program){this._program.destroy();}delete renderers$4[this._hash];stats.memory.programs--;}};EmphasisEdgesRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisEdgesRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState;var meshState=mesh._state;var geometry=mesh._geometry;var geometryState=geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
10368
|
+
mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$4[hash];if(!renderer){renderer=new EmphasisEdgesRenderer(hash,mesh);renderers$4[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisEdgesRenderer.prototype.put=function(){if(--this._useCount===0){ids.removeItem(this.id);if(this._program){this._program.destroy();}delete renderers$4[this._hash];stats.memory.programs--;}};EmphasisEdgesRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisEdgesRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState;var meshState=mesh._state;var geometry=mesh._geometry;var geometryState=geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$H);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}switch(mode){case 0:materialState=mesh._xrayMaterial._state;break;case 1:materialState=mesh._highlightMaterial._state;break;case 2:materialState=mesh._selectedMaterial._state;break;case 3:default:materialState=mesh._edgeMaterial._state;break;}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.lineWidth!==materialState.edgeWidth){gl.lineWidth(materialState.edgeWidth);frameCtx.lineWidth=materialState.edgeWidth;}if(this._uEdgeColor){var edgeColor=materialState.edgeColor;var edgeAlpha=materialState.edgeAlpha;gl.uniform4f(this._uEdgeColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
|
|
10368
10369
|
var indicesBuf;if(geometryState.primitive===gl.TRIANGLES){indicesBuf=geometry._getEdgeIndices();}else if(geometryState.primitive===gl.LINES){indicesBuf=geometryState.indicesBuf;}if(indicesBuf){if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}indicesBuf.bind();frameCtx.bindArray++;this._lastGeometryId=geometryState.id;}gl.drawElements(gl.LINES,indicesBuf.numItems,indicesBuf.itemType,0);frameCtx.drawElements++;}};EmphasisEdgesRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i119=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i119<len;_i119++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i119),pos:program.getLocation("sectionPlanePos"+_i119),dir:program.getLocation("sectionPlaneDir"+_i119)});}this._uEdgeColor=program.getLocation("edgeColor");this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisEdgesRenderer.prototype._bindProgram=function(frameCtx){var program=this._program;var scene=this._scene;var gl=scene.canvas.gl;var camera=scene.camera;var project=camera.project;program.bind();frameCtx.useProgram++;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
|
|
10369
10370
|
* @author xeolabs / https://github.com/xeolabs
|
|
10370
10371
|
*/ /**
|
|
10371
10372
|
* @private
|
|
10372
10373
|
*/var PickMeshShaderSource=/*#__PURE__*/_createClass(function PickMeshShaderSource(mesh){_classCallCheck(this,PickMeshShaderSource);this.vertex=buildVertex$3(mesh);this.fragment=buildFragment$3(mesh);});function buildVertex$3(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh picking vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("out vec4 vViewPosition;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");}src.push(" vec4 worldPosition = modelMatrix2 * localPosition;");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix2 * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$3(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Mesh picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform vec4 pickColor;");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = pickColor; ");src.push("}");return src;}/**
|
|
10373
10374
|
* @author xeolabs / https://github.com/xeolabs
|
|
10374
|
-
*/var tempVec3a$
|
|
10375
|
+
*/var tempVec3a$G=math.vec3();// No ID, because there is exactly one PickMeshRenderer per scene
|
|
10375
10376
|
/**
|
|
10376
10377
|
* @private
|
|
10377
|
-
*/var PickMeshRenderer=function PickMeshRenderer(hash,mesh){this._hash=hash;this._shaderSource=new PickMeshShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$3={};PickMeshRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.hash].join(";");var renderer=renderers$3[hash];if(!renderer){renderer=new PickMeshRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$3[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickMeshRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$3[this._hash];stats.memory.programs--;}};PickMeshRenderer.prototype.webglContextRestored=function(){this._program=null;};PickMeshRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
10378
|
+
*/var PickMeshRenderer=function PickMeshRenderer(hash,mesh){this._hash=hash;this._shaderSource=new PickMeshShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$3={};PickMeshRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.hash].join(";");var renderer=renderers$3[hash];if(!renderer){renderer=new PickMeshRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$3[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickMeshRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$3[this._hash];stats.memory.programs--;}};PickMeshRenderer.prototype.webglContextRestored=function(){this._program=null;};PickMeshRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$G);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}// Mesh-indexed color
|
|
10378
10379
|
var pickID=mesh._state.pickID;var a=pickID>>24&0xFF;var b=pickID>>16&0xFF;var g=pickID>>8&0xFF;var r=pickID&0xFF;gl.uniform4f(this._uPickColor,r/255,g/255,b/255,a/255);gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};PickMeshRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i120=0,len=clips.length;_i120<len;_i120++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i120),pos:program.getLocation("sectionPlanePos"+_i120),dir:program.getLocation("sectionPlaneDir"+_i120)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uPickColor=program.getLocation("pickColor");this._uPickClipPos=program.getLocation("pickClipPos");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastGeometryId=null;};PickMeshRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastGeometryId=null;};/**
|
|
10379
10380
|
* @private
|
|
10380
10381
|
*/var PickTriangleShaderSource=/*#__PURE__*/_createClass(function PickTriangleShaderSource(mesh){_classCallCheck(this,PickTriangleShaderSource);this.vertex=buildVertex$2(mesh);this.fragment=buildFragment$2(mesh);});function buildVertex$2(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push('#version 300 es');src.push("// Surface picking vertex shader");src.push("in vec3 position;");src.push("in vec4 color;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(clipping){src.push("uniform bool clippable;");src.push("out vec4 vWorldPosition;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("out vec4 vColor;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push(" vec4 worldPosition = modelMatrix * localPosition; ");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push(" vColor = color;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$2(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Surface picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");src.push("in vec4 vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var _i121=0;_i121<sectionPlanesState.getNumAllocatedSectionPlanes();_i121++){src.push("uniform bool sectionPlaneActive"+_i121+";");src.push("uniform vec3 sectionPlanePos"+_i121+";");src.push("uniform vec3 sectionPlaneDir"+_i121+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i122=0;_i122<sectionPlanesState.getNumAllocatedSectionPlanes();_i122++){src.push("if (sectionPlaneActive"+_i122+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i122+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i122+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}/**
|
|
10381
10382
|
* @author xeolabs / https://github.com/xeolabs
|
|
10382
|
-
*/var tempVec3a$
|
|
10383
|
+
*/var tempVec3a$F=math.vec3();/**
|
|
10383
10384
|
* @private
|
|
10384
|
-
*/var PickTriangleRenderer=function PickTriangleRenderer(hash,mesh){this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new PickTriangleShaderSource(mesh);this._allocate(mesh);};var renderers$2={};PickTriangleRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$2[hash];if(!renderer){renderer=new PickTriangleRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$2[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickTriangleRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$2[this._hash];stats.memory.programs--;}};PickTriangleRenderer.prototype.webglContextRestored=function(){this._program=null;};PickTriangleRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometry=mesh._geometry;var geometryState=mesh._geometry._state;var origin=mesh.origin;var backfaces=materialState.backfaces;var frontface=materialState.frontface;var project=scene.camera.project;var positionsBuf=geometry._getPickTrianglePositions();var pickColorsBuf=geometry._getPickTriangleColors();this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
10385
|
+
*/var PickTriangleRenderer=function PickTriangleRenderer(hash,mesh){this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new PickTriangleShaderSource(mesh);this._allocate(mesh);};var renderers$2={};PickTriangleRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$2[hash];if(!renderer){renderer=new PickTriangleRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$2[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickTriangleRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$2[this._hash];stats.memory.programs--;}};PickTriangleRenderer.prototype.webglContextRestored=function(){this._program=null;};PickTriangleRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometry=mesh._geometry;var geometryState=mesh._geometry._state;var origin=mesh.origin;var backfaces=materialState.backfaces;var frontface=materialState.frontface;var project=scene.camera.project;var positionsBuf=geometry._getPickTrianglePositions();var pickColorsBuf=geometry._getPickTriangleColors();this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$F);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);if(scene.logarithmicDepthBufferEnabled){gl.uniform1f(this._uZFar,scene.camera.project.far);}if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);}else{this._aPosition.bindArrayBuffer(positionsBuf);}gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);pickColorsBuf.bind();gl.enableVertexAttribArray(this._aColor.location);gl.vertexAttribPointer(this._aColor.location,pickColorsBuf.itemSize,pickColorsBuf.itemType,true,0,0);// Normalize
|
|
10385
10386
|
gl.drawArrays(geometryState.primitive,0,positionsBuf.numItems/3);};PickTriangleRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);this._useCount=0;if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var sectionPlanes=scene._sectionPlanesState.sectionPlanes;for(var _i123=0,len=sectionPlanes.length;_i123<len;_i123++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i123),pos:program.getLocation("sectionPlanePos"+_i123),dir:program.getLocation("sectionPlaneDir"+_i123)});}this._aPosition=program.getAttribute("position");this._aColor=program.getAttribute("color");this._uPickClipPos=program.getLocation("pickClipPos");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}};/**
|
|
10386
10387
|
* @author xeolabs / https://github.com/xeolabs
|
|
10387
10388
|
*/ /**
|
|
10388
10389
|
* @private
|
|
10389
10390
|
*/var OcclusionShaderSource=/*#__PURE__*/_createClass(function OcclusionShaderSource(mesh){_classCallCheck(this,OcclusionShaderSource);this.vertex=buildVertex$1(mesh);this.fragment=buildFragment$1(mesh);});function buildVertex$1(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");return src;}function buildFragment$1(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}/**
|
|
10390
10391
|
* @author xeolabs / https://github.com/xeolabs
|
|
10391
|
-
*/var tempVec3a$
|
|
10392
|
+
*/var tempVec3a$E=math.vec3();// No ID, because there is exactly one PickMeshRenderer per scene
|
|
10392
10393
|
/**
|
|
10393
10394
|
* @private
|
|
10394
|
-
*/var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(materialState.alpha<1.0){return;}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$
|
|
10395
|
+
*/var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(materialState.alpha<1.0){return;}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$E);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};OcclusionRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i124=0,len=clips.length;_i124<len;_i124++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i124),pos:program.getLocation("sectionPlanePos"+_i124),dir:program.getLocation("sectionPlaneDir"+_i124)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};OcclusionRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var project=scene.camera.project;var gl=scene.canvas.gl;this._program.bind();frameCtx.useProgram++;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};/**
|
|
10395
10396
|
* @private
|
|
10396
10397
|
*/var ShadowShaderSource=/*#__PURE__*/_createClass(function ShadowShaderSource(mesh){_classCallCheck(this,ShadowShaderSource);this.vertex=buildVertex(mesh);this.fragment=buildFragment(mesh);});function buildVertex(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push("// Mesh shadow vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("worldPosition = modelMatrix * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");return src;}function buildFragment(mesh){var scene=mesh.scene;scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("// Mesh shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("vec4 encodeFloat( const in float depth ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(depth * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push("outColor = encodeFloat(gl_FragCoord.z);");src.push("}");return src;}/**
|
|
10397
10398
|
* @private
|
|
@@ -11463,7 +11464,7 @@ geometry:new ReadableGeometry(axisGizmoScene,buildVectorTextGeometry({text:"Z",s
|
|
|
11463
11464
|
* @param visible
|
|
11464
11465
|
*/_createClass(AxisGizmoPlugin,[{key:"setVisible",value:function setVisible(visible){for(var _i130=0;_i130<this._meshes.length;_i130++){this._meshes[_i130].visible=visible;}}/**
|
|
11465
11466
|
* Destroys this AxisGizmoPlugin.
|
|
11466
|
-
*/},{key:"destroy",value:function destroy(){this._axisGizmoCanvas=null;this._axisGizmoScene.destroy();this._axisGizmoScene=null;_get(_getPrototypeOf(AxisGizmoPlugin.prototype),"destroy",this).call(this);}}]);return AxisGizmoPlugin;}(Plugin);math.vec3();/**
|
|
11467
|
+
*/},{key:"destroy",value:function destroy(){this._axisGizmoCanvas=null;this._axisGizmoScene.destroy();this._axisGizmoScene=null;_get(_getPrototypeOf(AxisGizmoPlugin.prototype),"destroy",this).call(this);}}]);return AxisGizmoPlugin;}(Plugin);var tempVec3a$D=math.vec3();var tempVec3b$y=math.vec3();var tempVec4a$a=math.vec4();var front=math.vec3([0,0,-1]);var back=math.vec3([0,0,1]);var up=math.vec3([0,1,0]);/**
|
|
11467
11468
|
* @desc An arbitrarily-aligned World-space clipping plane.
|
|
11468
11469
|
*
|
|
11469
11470
|
* * Slices portions off objects to create cross-section views or reveal interiors.
|
|
@@ -11515,7 +11516,7 @@ geometry:new ReadableGeometry(axisGizmoScene,buildVectorTextGeometry({text:"Z",s
|
|
|
11515
11516
|
* @param {Boolean} [cfg.active=true] Indicates whether or not this SectionPlane is active.
|
|
11516
11517
|
* @param {Number[]} [cfg.pos=[0,0,0]] World-space position of the SectionPlane.
|
|
11517
11518
|
* @param {Number[]} [cfg.dir=[0,0,-1]] Vector perpendicular to the plane surface, indicating the SectionPlane plane orientation.
|
|
11518
|
-
*/function SectionPlane(owner){var _this64;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,SectionPlane);_this64=_super42.call(this,owner,cfg);_this64._state=new RenderState({active:true,pos:math.vec3(),dir:math.vec3(),dist:0});_this64.active=cfg.active;_this64.pos=cfg.pos;_this64.dir=cfg.dir;_this64.scene._sectionPlaneCreated(_assertThisInitialized(_this64));return _this64;}/**
|
|
11519
|
+
*/function SectionPlane(owner){var _this64;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,SectionPlane);_this64=_super42.call(this,owner,cfg);_this64._state=new RenderState({active:true,pos:math.vec3(),quaternion:math.vec4(),roll:0,dir:math.vec3(),dist:0});_this64.active=cfg.active;_this64.pos=cfg.pos;_this64.dir=cfg.dir;_this64.scene._sectionPlaneCreated(_assertThisInitialized(_this64));return _this64;}/**
|
|
11519
11520
|
* Sets if this SectionPlane is active or not.
|
|
11520
11521
|
*
|
|
11521
11522
|
* Default value is ````true````.
|
|
@@ -11542,12 +11543,36 @@ geometry:new ReadableGeometry(axisGizmoScene,buildVectorTextGeometry({text:"Z",s
|
|
|
11542
11543
|
*
|
|
11543
11544
|
* @returns {Number[]} Current position.
|
|
11544
11545
|
*/function get(){return this._state.pos;}/**
|
|
11546
|
+
* Sets the quaternion of this SectionPlane's plane.
|
|
11547
|
+
*
|
|
11548
|
+
* Default value is ````[0, -1, 0, 0]````.
|
|
11549
|
+
*
|
|
11550
|
+
* @param {Number[]} value New quaternion.
|
|
11551
|
+
*/,set:function set(value){this._state.pos.set(value||[0,0,0]);this._state.dist=-math.dotVec3(this._state.pos,this._state.dir);this.fire("pos",this._state.pos);this.scene.fire("sectionPlaneUpdated",this);}},{key:"quaternion",get:/**
|
|
11552
|
+
* Gets the quaternion of this SectionPlane's plane.
|
|
11553
|
+
*
|
|
11554
|
+
* Default value is ````[0, -1, 0, 0]````.
|
|
11555
|
+
*
|
|
11556
|
+
* @returns {Number[]} value Current quaternion.
|
|
11557
|
+
*/function get(){return this._state.quaternion;}/**
|
|
11558
|
+
* Sets the roll of this SectionPlane's plane.
|
|
11559
|
+
*
|
|
11560
|
+
* Default value is ````0````.
|
|
11561
|
+
*
|
|
11562
|
+
* @param {Number[]} value New roll.
|
|
11563
|
+
*/,set:function set(value){this._state.quaternion.set(value||[0,0,0,-1]);math.vec3ApplyQuaternion(this._state.quaternion,back,this._state.dir);var quatUp=math.vec3ApplyQuaternion(this._state.quaternion,up,tempVec3a$D);var dirOnlyQ=math.vec3PairToQuaternion(back,this._state.dir,tempVec4a$a);var dirOnlyUp=math.vec3ApplyQuaternion(dirOnlyQ,up,tempVec3b$y);var angle=Math.acos(Math.min(1,math.dotVec3(quatUp,dirOnlyUp)));var sign=Math.sign(math.dotVec3(this._state.dir,math.cross3Vec3(quatUp,dirOnlyUp,tempVec3b$y)));this._state.roll=sign*angle;this._onDirUpdated();}},{key:"roll",get:/**
|
|
11564
|
+
* Gets the roll of this SectionPlane's plane.
|
|
11565
|
+
*
|
|
11566
|
+
* Default value is ````0````.
|
|
11567
|
+
*
|
|
11568
|
+
* @returns {Number[]} value Current roll.
|
|
11569
|
+
*/function get(){return this._state.roll;}/**
|
|
11545
11570
|
* Sets the direction of this SectionPlane's plane.
|
|
11546
11571
|
*
|
|
11547
11572
|
* Default value is ````[0, 0, -1]````.
|
|
11548
11573
|
*
|
|
11549
11574
|
* @param {Number[]} value New direction.
|
|
11550
|
-
*/,set:function set(value){this._state.
|
|
11575
|
+
*/,set:function set(value){this._state.roll=value||0;this._onDirRollUpdated();}},{key:"dir",get:/**
|
|
11551
11576
|
* Gets the direction of this SectionPlane's plane.
|
|
11552
11577
|
*
|
|
11553
11578
|
* Default value is ````[0, 0, -1]````.
|
|
@@ -11560,7 +11585,7 @@ geometry:new ReadableGeometry(axisGizmoScene,buildVectorTextGeometry({text:"Z",s
|
|
|
11560
11585
|
* each time either of two properties are updated.
|
|
11561
11586
|
*
|
|
11562
11587
|
* @returns {Number}
|
|
11563
|
-
*/,set:function set(value){this._state.dir.set(value||[0
|
|
11588
|
+
*/,set:function set(value){this._state.dir.set(value||front);this._onDirRollUpdated();}},{key:"_onDirRollUpdated",value:function _onDirRollUpdated(){math.vec3PairToQuaternion(back,this._state.dir,this._state.quaternion);tempVec4a$a[0]=0;tempVec4a$a[1]=0;tempVec4a$a[2]=-1;tempVec4a$a[3]=this._state.roll;math.angleAxisToQuaternion(tempVec4a$a,tempVec4a$a);math.mulQuaternions(this._state.quaternion,tempVec4a$a,this._state.quaternion);this._onDirUpdated();}},{key:"_onDirUpdated",value:function _onDirUpdated(){this._state.dist=-math.dotVec3(this._state.pos,this._state.dir);this.glRedraw();this.fire("dir",this._state.dir);this.scene.fire("sectionPlaneUpdated",this);}},{key:"dist",get:function get(){return this._state.dist;}/**
|
|
11564
11589
|
* Inverts the direction of {@link SectionPlane#dir}.
|
|
11565
11590
|
*/},{key:"flipDir",value:function flipDir(){math.mulVec3Scalar(this._state.dir,-1.0,this._state.dir);this.dir=this._state.dir;}/**
|
|
11566
11591
|
* @destroy
|
|
@@ -13184,8 +13209,8 @@ if(p===UnsignedInt248Type){return gl.UNSIGNED_INT_24_8;}if(p===RepeatWrapping){r
|
|
|
13184
13209
|
* @desc A low-level component that represents a 2D WebGL texture.
|
|
13185
13210
|
*
|
|
13186
13211
|
* @private
|
|
13187
|
-
*/var Texture2D=/*#__PURE__*/function(){function Texture2D(
|
|
13188
|
-
}this.allocated=true;}_createClass(Texture2D,[{key:"setPreloadColor",value:function setPreloadColor(value){if(!value){color$4[0]=0;color$4[1]=0;color$4[2]=0;color$4[3]=255;}else{color$4[0]=Math.floor(value[0]*255);color$4[1]=Math.floor(value[1]*255);color$4[2]=Math.floor(value[2]*255);color$4[3]=Math.floor((value[3]!==undefined?value[3]:1)*255);}var gl=this.gl;gl.bindTexture(this.target,this.texture);if(this.target===gl.TEXTURE_CUBE_MAP){var faces=[gl.TEXTURE_CUBE_MAP_POSITIVE_X,gl.TEXTURE_CUBE_MAP_NEGATIVE_X,gl.TEXTURE_CUBE_MAP_POSITIVE_Y,gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,gl.TEXTURE_CUBE_MAP_POSITIVE_Z,gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(var _i154=0,len=faces.length;_i154<len;_i154++){gl.texImage2D(faces[_i154],0,gl.RGBA,1,1,0,gl.RGBA,gl.UNSIGNED_BYTE,color$4);}}else{gl.texImage2D(this.target,0,gl.RGBA,1,1,0,gl.RGBA,gl.UNSIGNED_BYTE,color$4);}gl.bindTexture(this.target,null);}},{key:"setTarget",value:function setTarget(target){this.target=target||this.gl.TEXTURE_2D;}},{key:"setImage",value:function setImage(image){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var gl=this.gl;if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.flipY!==undefined){this.flipY=props.flipY;}if(props.premultiplyAlpha!==undefined){this.premultiplyAlpha=props.premultiplyAlpha;}if(props.unpackAlignment!==undefined){this.unpackAlignment=props.unpackAlignment;}if(props.minFilter!==undefined){this.minFilter=props.minFilter;}if(props.magFilter!==undefined){this.magFilter=props.magFilter;}if(props.wrapS!==undefined){this.wrapS=props.wrapS;}if(props.wrapT!==undefined){this.wrapT=props.wrapT;}if(props.wrapR!==undefined){this.wrapR=props.wrapR;}var generateMipMap=false;gl.bindTexture(this.target,this.texture);var bak1=gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this.flipY);var bak2=gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);var bak3=gl.getParameter(gl.UNPACK_ALIGNMENT);gl.pixelStorei(gl.UNPACK_ALIGNMENT,this.unpackAlignment);var bak4=gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,gl.NONE);var minFilter=convertConstant(gl,this.minFilter);gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,minFilter);if(minFilter===gl.NEAREST_MIPMAP_NEAREST||minFilter===gl.LINEAR_MIPMAP_NEAREST||minFilter===gl.NEAREST_MIPMAP_LINEAR||minFilter===gl.LINEAR_MIPMAP_LINEAR){generateMipMap=true;}var magFilter=convertConstant(gl,this.magFilter);if(magFilter){gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,magFilter);}var wrapS=convertConstant(gl,this.wrapS);if(wrapS){gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}var wrapT=convertConstant(gl,this.wrapT);if(wrapT){gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}var glFormat=convertConstant(gl,this.format,this.encoding);var glType=convertConstant(gl,this.type);var glInternalFormat=getInternalFormat(gl,this.internalFormat,glFormat,glType,this.encoding,false);if(this.target===gl.TEXTURE_CUBE_MAP){if(utils.isArray(image)){var images=image;var faces=[gl.TEXTURE_CUBE_MAP_POSITIVE_X,gl.TEXTURE_CUBE_MAP_NEGATIVE_X,gl.TEXTURE_CUBE_MAP_POSITIVE_Y,gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,gl.TEXTURE_CUBE_MAP_POSITIVE_Z,gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(var _i155=0,len=faces.length;_i155<len;_i155++){gl.texImage2D(faces[_i155],0,glInternalFormat,glFormat,glType,images[_i155]);}}}else{gl.texImage2D(gl.TEXTURE_2D,0,glInternalFormat,glFormat,glType,image);}if(generateMipMap){gl.generateMipmap(this.target);}gl.bindTexture(this.target,null);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,bak1);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,bak2);gl.pixelStorei(gl.UNPACK_ALIGNMENT,bak3);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,bak4);}},{key:"setCompressedData",value:function setCompressedData(
|
|
13212
|
+
*/var Texture2D=/*#__PURE__*/function(){function Texture2D(_ref6){var gl=_ref6.gl,target=_ref6.target,format=_ref6.format,type=_ref6.type,wrapS=_ref6.wrapS,wrapT=_ref6.wrapT,wrapR=_ref6.wrapR,encoding=_ref6.encoding,preloadColor=_ref6.preloadColor,premultiplyAlpha=_ref6.premultiplyAlpha,flipY=_ref6.flipY;_classCallCheck(this,Texture2D);this.gl=gl;this.target=target||gl.TEXTURE_2D;this.format=format||RGBAFormat;this.type=type||UnsignedByteType;this.internalFormat=null;this.premultiplyAlpha=!!premultiplyAlpha;this.flipY=!!flipY;this.unpackAlignment=4;this.wrapS=wrapS||RepeatWrapping;this.wrapT=wrapT||RepeatWrapping;this.wrapR=wrapR||RepeatWrapping;this.encoding=encoding||sRGBEncoding;this.texture=gl.createTexture();if(preloadColor){this.setPreloadColor(preloadColor);// Prevents "there is no texture bound to the unit 0" error
|
|
13213
|
+
}this.allocated=true;}_createClass(Texture2D,[{key:"setPreloadColor",value:function setPreloadColor(value){if(!value){color$4[0]=0;color$4[1]=0;color$4[2]=0;color$4[3]=255;}else{color$4[0]=Math.floor(value[0]*255);color$4[1]=Math.floor(value[1]*255);color$4[2]=Math.floor(value[2]*255);color$4[3]=Math.floor((value[3]!==undefined?value[3]:1)*255);}var gl=this.gl;gl.bindTexture(this.target,this.texture);if(this.target===gl.TEXTURE_CUBE_MAP){var faces=[gl.TEXTURE_CUBE_MAP_POSITIVE_X,gl.TEXTURE_CUBE_MAP_NEGATIVE_X,gl.TEXTURE_CUBE_MAP_POSITIVE_Y,gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,gl.TEXTURE_CUBE_MAP_POSITIVE_Z,gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(var _i154=0,len=faces.length;_i154<len;_i154++){gl.texImage2D(faces[_i154],0,gl.RGBA,1,1,0,gl.RGBA,gl.UNSIGNED_BYTE,color$4);}}else{gl.texImage2D(this.target,0,gl.RGBA,1,1,0,gl.RGBA,gl.UNSIGNED_BYTE,color$4);}gl.bindTexture(this.target,null);}},{key:"setTarget",value:function setTarget(target){this.target=target||this.gl.TEXTURE_2D;}},{key:"setImage",value:function setImage(image){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var gl=this.gl;if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.flipY!==undefined){this.flipY=props.flipY;}if(props.premultiplyAlpha!==undefined){this.premultiplyAlpha=props.premultiplyAlpha;}if(props.unpackAlignment!==undefined){this.unpackAlignment=props.unpackAlignment;}if(props.minFilter!==undefined){this.minFilter=props.minFilter;}if(props.magFilter!==undefined){this.magFilter=props.magFilter;}if(props.wrapS!==undefined){this.wrapS=props.wrapS;}if(props.wrapT!==undefined){this.wrapT=props.wrapT;}if(props.wrapR!==undefined){this.wrapR=props.wrapR;}var generateMipMap=false;gl.bindTexture(this.target,this.texture);var bak1=gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this.flipY);var bak2=gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);var bak3=gl.getParameter(gl.UNPACK_ALIGNMENT);gl.pixelStorei(gl.UNPACK_ALIGNMENT,this.unpackAlignment);var bak4=gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,gl.NONE);var minFilter=convertConstant(gl,this.minFilter);gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,minFilter);if(minFilter===gl.NEAREST_MIPMAP_NEAREST||minFilter===gl.LINEAR_MIPMAP_NEAREST||minFilter===gl.NEAREST_MIPMAP_LINEAR||minFilter===gl.LINEAR_MIPMAP_LINEAR){generateMipMap=true;}var magFilter=convertConstant(gl,this.magFilter);if(magFilter){gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,magFilter);}var wrapS=convertConstant(gl,this.wrapS);if(wrapS){gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}var wrapT=convertConstant(gl,this.wrapT);if(wrapT){gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}var glFormat=convertConstant(gl,this.format,this.encoding);var glType=convertConstant(gl,this.type);var glInternalFormat=getInternalFormat(gl,this.internalFormat,glFormat,glType,this.encoding,false);if(this.target===gl.TEXTURE_CUBE_MAP){if(utils.isArray(image)){var images=image;var faces=[gl.TEXTURE_CUBE_MAP_POSITIVE_X,gl.TEXTURE_CUBE_MAP_NEGATIVE_X,gl.TEXTURE_CUBE_MAP_POSITIVE_Y,gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,gl.TEXTURE_CUBE_MAP_POSITIVE_Z,gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];for(var _i155=0,len=faces.length;_i155<len;_i155++){gl.texImage2D(faces[_i155],0,glInternalFormat,glFormat,glType,images[_i155]);}}}else{gl.texImage2D(gl.TEXTURE_2D,0,glInternalFormat,glFormat,glType,image);}if(generateMipMap){gl.generateMipmap(this.target);}gl.bindTexture(this.target,null);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,bak1);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,bak2);gl.pixelStorei(gl.UNPACK_ALIGNMENT,bak3);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,bak4);}},{key:"setCompressedData",value:function setCompressedData(_ref7){var mipmaps=_ref7.mipmaps,_ref7$props=_ref7.props,props=_ref7$props===void 0?{}:_ref7$props;var gl=this.gl;var levels=mipmaps.length;// Cache props
|
|
13189
13214
|
if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.flipY!==undefined){this.flipY=props.flipY;}if(props.premultiplyAlpha!==undefined){this.premultiplyAlpha=props.premultiplyAlpha;}if(props.unpackAlignment!==undefined){this.unpackAlignment=props.unpackAlignment;}if(props.minFilter!==undefined){this.minFilter=props.minFilter;}if(props.magFilter!==undefined){this.magFilter=props.magFilter;}if(props.wrapS!==undefined){this.wrapS=props.wrapS;}if(props.wrapT!==undefined){this.wrapT=props.wrapT;}if(props.wrapR!==undefined){this.wrapR=props.wrapR;}gl.activeTexture(gl.TEXTURE0+0);gl.bindTexture(this.target,this.texture);var supportsMips=mipmaps.length>1;gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this.flipY);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);gl.pixelStorei(gl.UNPACK_ALIGNMENT,this.unpackAlignment);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,gl.NONE);var wrapS=convertConstant(gl,this.wrapS);if(wrapS){gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}var wrapT=convertConstant(gl,this.wrapT);if(wrapT){gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}if(this.type===gl.TEXTURE_3D||this.type===gl.TEXTURE_2D_ARRAY){var wrapR=convertConstant(gl,this.wrapR);if(wrapR){gl.texParameteri(this.target,gl.TEXTURE_WRAP_R,wrapR);}gl.texParameteri(this.type,gl.TEXTURE_WRAP_R,wrapR);}if(supportsMips){gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,filterFallback(gl,this.minFilter));gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,filterFallback(gl,this.magFilter));}else{gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,convertConstant(gl,this.minFilter));gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,convertConstant(gl,this.magFilter));}var glFormat=convertConstant(gl,this.format,this.encoding);var glType=convertConstant(gl,this.type);var glInternalFormat=getInternalFormat(gl,this.internalFormat,glFormat,glType,this.encoding,false);gl.texStorage2D(gl.TEXTURE_2D,levels,glInternalFormat,mipmaps[0].width,mipmaps[0].height);for(var _i156=0,len=mipmaps.length;_i156<len;_i156++){var mipmap=mipmaps[_i156];if(this.format!==RGBAFormat){if(glFormat!==null){gl.compressedTexSubImage2D(gl.TEXTURE_2D,_i156,0,0,mipmap.width,mipmap.height,glFormat,mipmap.data);}else{console.warn('Attempt to load unsupported compressed texture format in .setCompressedData()');}}else{gl.texSubImage2D(gl.TEXTURE_2D,_i156,0,0,mipmap.width,mipmap.height,glFormat,glType,mipmap.data);}}// if (generateMipMap) {
|
|
13190
13215
|
// // gl.generateMipmap(this.target); // Only for roughness textures?
|
|
13191
13216
|
// }
|
|
@@ -14843,7 +14868,7 @@ SILHOUETTE_HIGHLIGHTED:3,SILHOUETTE_SELECTED:4,SILHOUETTE_XRAYED:5,// Edges rend
|
|
|
14843
14868
|
EDGES_COLOR_OPAQUE:6,EDGES_COLOR_TRANSPARENT:7,EDGES_HIGHLIGHTED:8,EDGES_SELECTED:9,EDGES_XRAYED:10,// Picking
|
|
14844
14869
|
PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=new Float32Array([0,0,0,1]);var tempVec4=math.vec4();var tempVec3a$C=math.vec3();var tempVec3c$t=math.vec3();var tempMat4a$r=math.mat4();/**
|
|
14845
14870
|
* @private
|
|
14846
|
-
*/var VBORenderer=/*#__PURE__*/function(){function VBORenderer(scene){var withSAO=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var
|
|
14871
|
+
*/var VBORenderer=/*#__PURE__*/function(){function VBORenderer(scene){var withSAO=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$instancing=_ref8.instancing,instancing=_ref8$instancing===void 0?false:_ref8$instancing,_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges,_ref8$useAlphaCutoff=_ref8.useAlphaCutoff,useAlphaCutoff=_ref8$useAlphaCutoff===void 0?false:_ref8$useAlphaCutoff;_classCallCheck(this,VBORenderer);this._scene=scene;this._withSAO=withSAO;this._instancing=instancing;this._edges=edges;this._useAlphaCutoff=useAlphaCutoff;this._hash=this._getHash();/**
|
|
14847
14872
|
* Matrices Uniform Block Buffer
|
|
14848
14873
|
*
|
|
14849
14874
|
* In shaders, matrices in the Matrices Uniform Block MUST be set in this order:
|
|
@@ -14861,15 +14886,15 @@ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=ne
|
|
|
14861
14886
|
* @returns { string }
|
|
14862
14887
|
*/_createClass(VBORenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){return[""];}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){return[""];}},{key:"_addMatricesUniformBlockLines",value:function _addMatricesUniformBlockLines(src){var normals=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;src.push("uniform Matrices {");src.push(" mat4 worldMatrix;");src.push(" mat4 viewMatrix;");src.push(" mat4 projMatrix;");src.push(" mat4 positionsDecodeMatrix;");if(normals){src.push(" mat4 worldNormalMatrix;");src.push(" mat4 viewNormalMatrix;");}src.push("};");return src;}},{key:"_addRemapClipPosLines",value:function _addRemapClipPosLines(src){var viewportSize=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;src.push("uniform vec2 drawingBufferSize;");src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");if(viewportSize===1){src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");}else{src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * (drawingBufferSize / float(".concat(viewportSize,"));"));}src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");return src;}},{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"setSectionPlanesStateUniforms",value:function setSectionPlanesStateUniforms(layer){var scene=this._scene;var gl=scene.canvas.gl;var model=layer.model,layerIndex=layer.layerIndex;var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;if(scene.crossSections){gl.uniform4fv(this._uSliceColor,scene.crossSections.sliceColor);gl.uniform1f(this._uSliceThickness,scene.crossSections.sliceThickness);}for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];var origin=layer._state.origin;if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$C,model.matrix);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");if(!this._uColor){// some shader may have color as attribute, in this case the uniform must be renamed silhouetteColor
|
|
14863
14888
|
this._uColor=program.getLocation("silhouetteColor");}this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uPickInvisible=program.getLocation("pickInvisible");this._uGammaFactor=program.getLocation("gammaFactor");gl.uniformBlockBinding(program.handle,gl.getUniformBlockIndex(program.handle,"Matrices"),this._matricesUniformBlockBufferBindingPoint);this._uShadowViewMatrix=program.getLocation("shadowViewMatrix");this._uShadowProjMatrix=program.getLocation("shadowProjMatrix");if(scene.logarithmicDepthBufferEnabled){this._uZFar=program.getLocation("zFar");}this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];// TODO add a gard to prevent light params if not affected by light ?
|
|
14864
|
-
var lights=lightsState.lights;var light;for(var _i167=0,len=lights.length;_i167<len;_i167++){light=lights[_i167];switch(light.type){case"dir":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=null;this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);break;case"point":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=null;this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;case"spot":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i168=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i168<_len20;_i168++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i168),pos:program.getLocation("sectionPlanePos"+_i168),dir:program.getLocation("sectionPlaneDir"+_i168)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(this._useAlphaCutoff){this._alphaCutoffLocation=program.getLocation("materialAlphaCutoff");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");if(scene.crossSections){this._uSliceColor=program.getLocation("sliceColor");this._uSliceThickness=program.getLocation("sliceThickness");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i169=0,len=lights.length;_i169<len;_i169++){var light=lights[_i169];if(this._uLightColor[_i169]){gl.uniform4f(this._uLightColor[_i169],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i169]){gl.uniform3fv(this._uLightPos[_i169],light.pos);if(this._uLightAttenuation[_i169]){gl.uniform1f(this._uLightAttenuation[_i169],light.attenuation);}}if(this._uLightDir[_i169]){gl.uniform3fv(this._uLightDir[_i169],light.dir);}}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges&&state.edgeIndicesBuf){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges&&state.edgeIndicesBuf){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var
|
|
14889
|
+
var lights=lightsState.lights;var light;for(var _i167=0,len=lights.length;_i167<len;_i167++){light=lights[_i167];switch(light.type){case"dir":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=null;this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);break;case"point":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=null;this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;case"spot":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i168=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i168<_len20;_i168++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i168),pos:program.getLocation("sectionPlanePos"+_i168),dir:program.getLocation("sectionPlaneDir"+_i168)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(this._useAlphaCutoff){this._alphaCutoffLocation=program.getLocation("materialAlphaCutoff");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");if(scene.crossSections){this._uSliceColor=program.getLocation("sliceColor");this._uSliceThickness=program.getLocation("sliceThickness");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i169=0,len=lights.length;_i169<len;_i169++){var light=lights[_i169];if(this._uLightColor[_i169]){gl.uniform4f(this._uLightColor[_i169],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i169]){gl.uniform3fv(this._uLightPos[_i169],light.pos);if(this._uLightAttenuation[_i169]){gl.uniform1f(this._uLightAttenuation[_i169],light.attenuation);}}if(this._uLightDir[_i169]){gl.uniform3fv(this._uLightDir[_i169],light.dir);}}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges&&state.edgeIndicesBuf){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges&&state.edgeIndicesBuf){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref9=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref9$colorUniform=_ref9.colorUniform,colorUniform=_ref9$colorUniform===void 0?false:_ref9$colorUniform,_ref9$incrementDrawSt=_ref9.incrementDrawState,incrementDrawState=_ref9$incrementDrawSt===void 0?false:_ref9$incrementDrawSt;var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var state=layer._state,model=layer.model;var textureSet=state.textureSet,origin=state.origin,positionsDecodeMatrix=state.positionsDecodeMatrix;var lightsState=scene._lightsState;var pointsMaterial=scene.pointsMaterial;var camera=model.scene.camera;var viewNormalMatrix=camera.viewNormalMatrix,project=camera.project;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var position=model.position,rotationMatrix=model.rotationMatrix,worldNormalMatrix=model.worldNormalMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(this._vaoCache.has(layer)){gl.bindVertexArray(this._vaoCache.get(layer));}else{this._vaoCache.set(layer,this._makeVAO(state));}var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrix,0);var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$C;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$t);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];this._matricesUniformBlockBufferData.set(createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$r),offset+=mat4Size);}else{this._matricesUniformBlockBufferData.set(viewMatrix,offset+=mat4Size);}this._matricesUniformBlockBufferData.set(frameCtx.pickProjMatrix||project.matrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(positionsDecodeMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(worldNormalMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(viewNormalMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);gl.uniform1i(this._uRenderPass,renderPass);this.setSectionPlanesStateUniforms(layer);if(scene.logarithmicDepthBufferEnabled){if(this._uLogDepthBufFC){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
|
|
14865
14890
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uZFar){gl.uniform1f(this._uZFar,scene.camera.project.far);}}if(this._uPickInvisible){gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}if(this._uPickZNear){gl.uniform1f(this._uPickZNear,frameCtx.pickZNear);}if(this._uPickZFar){gl.uniform1f(this._uPickZFar,frameCtx.pickZFar);}if(this._uPickClipPos){gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);}if(this._uDrawingBufferSize){gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,state.uvDecodeMatrix);}if(this._uIntensityRange&&pointsMaterial.filterIntensity){gl.uniform2f(this._uIntensityRange,pointsMaterial.minIntensity,pointsMaterial.maxIntensity);}if(this._uPointSize){gl.uniform1f(this._uPointSize,pointsMaterial.pointSize);}if(this._uNearPlaneHeight){var nearPlaneHeight=scene.camera.projection==="ortho"?1.0:gl.drawingBufferHeight/(2*Math.tan(0.5*scene.camera.perspective.fov*Math.PI/180.0));gl.uniform1f(this._uNearPlaneHeight,nearPlaneHeight);}if(textureSet){var colorTexture=textureSet.colorTexture,metallicRoughnessTexture=textureSet.metallicRoughnessTexture,emissiveTexture=textureSet.emissiveTexture,normalsTexture=textureSet.normalsTexture,occlusionTexture=textureSet.occlusionTexture;if(this._uColorMap&&colorTexture){this._program.bindTexture(this._uColorMap,colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uMetallicRoughMap&&metallicRoughnessTexture){this._program.bindTexture(this._uMetallicRoughMap,metallicRoughnessTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uEmissiveMap&&emissiveTexture){this._program.bindTexture(this._uEmissiveMap,emissiveTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uNormalMap&&normalsTexture){this._program.bindTexture(this._uNormalMap,normalsTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uAOMap&&occlusionTexture){this._program.bindTexture(this._uAOMap,occlusionTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(lightsState.reflectionMaps.length>0&&lightsState.reflectionMaps[0].texture&&this._uReflectionMap){this._program.bindTexture(this._uReflectionMap,lightsState.reflectionMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(lightsState.lightMaps.length>0&&lightsState.lightMaps[0].texture&&this._uLightMap){this._program.bindTexture(this._uLightMap,lightsState.lightMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}if(this._useAlphaCutoff){gl.uniform1f(this._alphaCutoffLocation,textureSet.alphaCutoff);}if(colorUniform){var colorKey=this._edges?"edgeColor":"fillColor";var alphaKey=this._edges?"edgeAlpha":"fillAlpha";if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_XRAYED")]){var material=scene.xrayMaterial._state;var _color3=material[colorKey];var alpha=material[alphaKey];gl.uniform4f(this._uColor,_color3[0],_color3[1],_color3[2],alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_HIGHLIGHTED")]){var _material=scene.highlightMaterial._state;var _color4=_material[colorKey];var _alpha=_material[alphaKey];gl.uniform4f(this._uColor,_color4[0],_color4[1],_color4[2],_alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_SELECTED")]){var _material2=scene.selectedMaterial._state;var _color5=_material2[colorKey];var _alpha2=_material2[alphaKey];gl.uniform4f(this._uColor,_color5[0],_color5[1],_color5[2],_alpha2);}else{gl.uniform4fv(this._uColor,this._edges?edgesDefaultColor:defaultColor$2);}}this._draw({state:state,frameCtx:frameCtx,incrementDrawState:incrementDrawState});gl.bindVertexArray(null);}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;stats.memory.programs--;}}]);return VBORenderer;}();/**
|
|
14866
14891
|
* @private
|
|
14867
|
-
*/var TrianglesBatchingRenderer=/*#__PURE__*/function(_VBORenderer){_inherits(TrianglesBatchingRenderer,_VBORenderer);var _super51=_createSuper(TrianglesBatchingRenderer);function TrianglesBatchingRenderer(scene,withSAO){var
|
|
14892
|
+
*/var TrianglesBatchingRenderer=/*#__PURE__*/function(_VBORenderer){_inherits(TrianglesBatchingRenderer,_VBORenderer);var _super51=_createSuper(TrianglesBatchingRenderer);function TrianglesBatchingRenderer(scene,withSAO){var _ref10=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref10$edges=_ref10.edges,edges=_ref10$edges===void 0?false:_ref10$edges,_ref10$useAlphaCutoff=_ref10.useAlphaCutoff,useAlphaCutoff=_ref10$useAlphaCutoff===void 0?false:_ref10$useAlphaCutoff;_classCallCheck(this,TrianglesBatchingRenderer);return _super51.call(this,scene,withSAO,{instancing:false,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesBatchingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){if(state.edgeIndicesBuf){gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);}}else{var count=frameCtx.pickElementsCount||state.indicesBuf.numItems;var offset=frameCtx.pickElementsOffset?frameCtx.pickElementsOffset*state.indicesBuf.itemByteSize:0;gl.drawElements(gl.TRIANGLES,count,state.indicesBuf.itemType,offset);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return TrianglesBatchingRenderer;}(VBORenderer);/**
|
|
14868
14893
|
* @private
|
|
14869
14894
|
*/var TrianglesColorRenderer$1=/*#__PURE__*/function(_TrianglesBatchingRen){_inherits(TrianglesColorRenderer$1,_TrianglesBatchingRen);var _super52=_createSuper(TrianglesColorRenderer$1);function TrianglesColorRenderer$1(){_classCallCheck(this,TrianglesColorRenderer$1);return _super52.apply(this,arguments);}_createClass(TrianglesColorRenderer$1,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesColorRenderer$1.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var light;var src=[];src.push("#version 300 es");src.push("// Triangles batching draw vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src,true);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("uniform vec4 lightAmbient;");for(var _i170=0,len=lightsState.lights.length;_i170<len;_i170++){light=lightsState.lights[_i170];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i170+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i170+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i170+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i170+";");src.push("uniform vec3 lightDir"+_i170+";");}}src.push("vec3 octDecode(vec2 oct) {");src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");src.push(" if (v.z < 0.0) {");src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");src.push(" }");src.push(" return normalize(v);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
14870
14895
|
// renderPass = COLOR_OPAQUE
|
|
14871
14896
|
src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
|
|
14872
|
-
src.push("} else {");src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i171=0,_len21=lightsState.lights.length;_i171<_len21;_i171++){light=lightsState.lights[_i171];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i171+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i171+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i171+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i171+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i171+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i171+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i171+".rgb * lightColor"+_i171+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i172=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i172<len;_i172++){src.push("uniform bool sectionPlaneActive"+_i172+";");src.push("uniform vec3 sectionPlanePos"+_i172+";");src.push("uniform vec3 sectionPlaneDir"+_i172+";");}src.push("uniform float sliceThickness;");src.push("uniform vec4 sliceColor;");}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec4 newColor;");src.push(" newColor = vColor;");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i173=0,_len22=sectionPlanesState.getNumAllocatedSectionPlanes();_i173<_len22;_i173++){src.push("if (sectionPlaneActive"+_i173+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i173+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i173+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > sliceThickness) { ");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" newColor = sliceColor;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
14897
|
+
src.push("} else {");src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i171=0,_len21=lightsState.lights.length;_i171<_len21;_i171++){light=lightsState.lights[_i171];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i171+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i171+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i171+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i171+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i171+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i171+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i171+".rgb * lightColor"+_i171+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i172=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i172<len;_i172++){src.push("uniform bool sectionPlaneActive"+_i172+";");src.push("uniform vec3 sectionPlanePos"+_i172+";");src.push("uniform vec3 sectionPlaneDir"+_i172+";");}src.push("uniform float sliceThickness;");src.push("uniform vec4 sliceColor;");}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec4 newColor;");src.push(" newColor = vColor;");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i173=0,_len22=sectionPlanesState.getNumAllocatedSectionPlanes();_i173<_len22;_i173++){src.push("if (sectionPlaneActive"+_i173+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i173+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i173+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > sliceThickness) { ");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" newColor = sliceColor;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
14873
14898
|
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
14874
14899
|
src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");}else{src.push(" outColor = newColor;");}src.push("}");return src;}}]);return TrianglesColorRenderer$1;}(TrianglesBatchingRenderer);/**
|
|
14875
14900
|
* @private
|
|
@@ -15195,13 +15220,13 @@ var a=tempVec3d$a;var b=tempVec3e$1;var c=tempVec3f$1;var gotIntersect=false;var
|
|
|
15195
15220
|
math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}// ---------
|
|
15196
15221
|
},{key:"destroy",value:function destroy(){var state=this._state;if(state.positionsBuf){state.positionsBuf.destroy();state.positionsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.normalsBuf){state.normalsBuf.destroy();state.normalsBuf=null;}if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.metallicRoughnessBuf){state.metallicRoughnessBuf.destroy();state.metallicRoughnessBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.pickColorsBuf){state.pickColorsBuf.destroy();state.pickColorsBuf=null;}if(state.indicesBuf){state.indicesBuf.destroy();state.indicessBuf=null;}if(state.edgeIndicesBuf){state.edgeIndicesBuf.destroy();state.edgeIndicessBuf=null;}state.destroy();}}]);return VBOBatchingTrianglesLayer;}();/**
|
|
15197
15222
|
* @private
|
|
15198
|
-
*/var TrianglesInstancingRenderer=/*#__PURE__*/function(_VBORenderer4){_inherits(TrianglesInstancingRenderer,_VBORenderer4);var _super70=_createSuper(TrianglesInstancingRenderer);function TrianglesInstancingRenderer(scene,withSAO){var
|
|
15223
|
+
*/var TrianglesInstancingRenderer=/*#__PURE__*/function(_VBORenderer4){_inherits(TrianglesInstancingRenderer,_VBORenderer4);var _super70=_createSuper(TrianglesInstancingRenderer);function TrianglesInstancingRenderer(scene,withSAO){var _ref11=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref11$edges=_ref11.edges,edges=_ref11$edges===void 0?false:_ref11$edges,_ref11$useAlphaCutoff=_ref11.useAlphaCutoff,useAlphaCutoff=_ref11$useAlphaCutoff===void 0?false:_ref11$useAlphaCutoff;_classCallCheck(this,TrianglesInstancingRenderer);return _super70.call(this,scene,withSAO,{instancing:true,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesInstancingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){if(state.edgeIndicesBuf){gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);}}else{gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return TrianglesInstancingRenderer;}(VBORenderer);/**
|
|
15199
15224
|
* @private
|
|
15200
15225
|
*/var TrianglesColorRenderer=/*#__PURE__*/function(_TrianglesInstancingR){_inherits(TrianglesColorRenderer,_TrianglesInstancingR);var _super71=_createSuper(TrianglesColorRenderer);function TrianglesColorRenderer(){_classCallCheck(this,TrianglesColorRenderer);return _super71.apply(this,arguments);}_createClass(TrianglesColorRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var i;var len;var light;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec2 normal;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
|
|
15201
15226
|
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("in vec4 modelNormalMatrixCol0;");src.push("in vec4 modelNormalMatrixCol1;");src.push("in vec4 modelNormalMatrixCol2;");this._addMatricesUniformBlockLines(src,true);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("vec3 octDecode(vec2 oct) {");src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");src.push(" if (v.z < 0.0) {");src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");src.push(" }");src.push(" return normalize(v);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
15202
15227
|
// renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
15203
15228
|
src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
|
|
15204
|
-
src.push("} else {");src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i225=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i225<len;_i225++){src.push("uniform bool sectionPlaneActive"+_i225+";");src.push("uniform vec3 sectionPlanePos"+_i225+";");src.push("uniform vec3 sectionPlaneDir"+_i225+";");}src.push("uniform float sliceThickness;");src.push("uniform vec4 sliceColor;");}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec4 newColor;");src.push(" newColor = vColor;");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i226=0,_len44=sectionPlanesState.getNumAllocatedSectionPlanes();_i226<_len44;_i226++){src.push("if (sectionPlaneActive"+_i226+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i226+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i226+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > sliceThickness) { ");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" newColor = sliceColor;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
15229
|
+
src.push("} else {");src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i225=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i225<len;_i225++){src.push("uniform bool sectionPlaneActive"+_i225+";");src.push("uniform vec3 sectionPlanePos"+_i225+";");src.push("uniform vec3 sectionPlaneDir"+_i225+";");}src.push("uniform float sliceThickness;");src.push("uniform vec4 sliceColor;");}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec4 newColor;");src.push(" newColor = vColor;");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i226=0,_len44=sectionPlanesState.getNumAllocatedSectionPlanes();_i226<_len44;_i226++){src.push("if (sectionPlaneActive"+_i226+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i226+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i226+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > sliceThickness) { ");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" newColor = sliceColor;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
15205
15230
|
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
15206
15231
|
if(this._withSAO){src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");}else{src.push(" outColor = newColor;");}src.push("}");return src;}}]);return TrianglesColorRenderer;}(TrianglesInstancingRenderer);/**
|
|
15207
15232
|
* @private
|
|
@@ -15672,7 +15697,7 @@ var _notNormalized6=false;this._state.flagsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,n
|
|
|
15672
15697
|
},{key:"initFlags",value:function initFlags(portionId,flags,meshTransparent){if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}if(meshTransparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setVisible",value:function setVisible(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.VISIBLE){this._numVisibleLayerPortions++;this.model.numVisibleLayerPortions++;}else{this._numVisibleLayerPortions--;this.model.numVisibleLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setHighlighted",value:function setHighlighted(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.HIGHLIGHTED){this._numHighlightedLayerPortions++;this.model.numHighlightedLayerPortions++;}else{this._numHighlightedLayerPortions--;this.model.numHighlightedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setXRayed",value:function setXRayed(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.XRAYED){this._numXRayedLayerPortions++;this.model.numXRayedLayerPortions++;}else{this._numXRayedLayerPortions--;this.model.numXRayedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setSelected",value:function setSelected(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.SELECTED){this._numSelectedLayerPortions++;this.model.numSelectedLayerPortions++;}else{this._numSelectedLayerPortions--;this.model.numSelectedLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setEdges",value:function setEdges(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.EDGES){this._numEdgesLayerPortions++;this.model.numEdgesLayerPortions++;}else{this._numEdgesLayerPortions--;this.model.numEdgesLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setClippable",value:function setClippable(portionId,flags){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CLIPPABLE){this._numClippableLayerPortions++;this.model.numClippableLayerPortions++;}else{this._numClippableLayerPortions--;this.model.numClippableLayerPortions--;}this._setFlags(portionId,flags);}},{key:"setCollidable",value:function setCollidable(portionId,flags){if(!this._finalized){throw"Not finalized";}}},{key:"setPickable",value:function setPickable(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.PICKABLE){this._numPickableLayerPortions++;this.model.numPickableLayerPortions++;}else{this._numPickableLayerPortions--;this.model.numPickableLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setCulled",value:function setCulled(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}if(flags&ENTITY_FLAGS.CULLED){this._numCulledLayerPortions++;this.model.numCulledLayerPortions++;}else{this._numCulledLayerPortions--;this.model.numCulledLayerPortions--;}this._setFlags(portionId,flags,meshTransparent);}},{key:"setColor",value:function setColor(portionId,color){// RGBA color is normalized as ints
|
|
15673
15698
|
if(!this._finalized){throw"Not finalized";}tempUint8Vec4$1[0]=color[0];tempUint8Vec4$1[1]=color[1];tempUint8Vec4$1[2]=color[2];tempUint8Vec4$1[3]=color[3];this._state.colorsBuf.setData(tempUint8Vec4$1,portionId*4,4);}},{key:"setTransparent",value:function setTransparent(portionId,flags,transparent){if(transparent){this._numTransparentLayerPortions++;this.model.numTransparentLayerPortions++;}else{this._numTransparentLayerPortions--;this.model.numTransparentLayerPortions--;}this._setFlags(portionId,flags,transparent);}/**
|
|
15674
15699
|
* flags are 4bits values encoded on a 32bit base. color flag on the first 4 bits, silhouette flag on the next 4 bits and so on for edge, pick and clippable.
|
|
15675
|
-
*/},{key:"_setFlags",value:function _setFlags(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}var visible=!!(flags&ENTITY_FLAGS.VISIBLE);var xrayed=!!(flags&ENTITY_FLAGS.XRAYED);var highlighted=!!(flags&ENTITY_FLAGS.HIGHLIGHTED);var selected=!!(flags&ENTITY_FLAGS.SELECTED);var edges=!!(flags&ENTITY_FLAGS.EDGES);var pickable=!!(flags&ENTITY_FLAGS.PICKABLE);var culled=!!(flags&ENTITY_FLAGS.CULLED);var colorFlag;if(!visible||culled||xrayed||highlighted&&!this.model.scene.highlightMaterial.glowThrough||selected&&!this.model.scene.selectedMaterial.glowThrough){colorFlag=RENDER_PASSES.NOT_RENDERED;}else{if(meshTransparent){colorFlag=RENDER_PASSES.COLOR_TRANSPARENT;}else{colorFlag=RENDER_PASSES.COLOR_OPAQUE;}}var silhouetteFlag;if(!visible||culled){silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){silhouetteFlag=RENDER_PASSES.SILHOUETTE_SELECTED;}else if(highlighted){silhouetteFlag=RENDER_PASSES.SILHOUETTE_HIGHLIGHTED;}else if(xrayed){silhouetteFlag=RENDER_PASSES.SILHOUETTE_XRAYED;}else{silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}var edgeFlag=0;if(!visible||culled){edgeFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){edgeFlag=RENDER_PASSES.EDGES_SELECTED;}else if(highlighted){edgeFlag=RENDER_PASSES.EDGES_HIGHLIGHTED;}else if(xrayed){edgeFlag=RENDER_PASSES.EDGES_XRAYED;}else if(edges){if(meshTransparent){edgeFlag=RENDER_PASSES.EDGES_COLOR_TRANSPARENT;}else{edgeFlag=RENDER_PASSES.EDGES_COLOR_OPAQUE;}}else{edgeFlag=RENDER_PASSES.NOT_RENDERED;}var pickFlag=visible&&!culled&&pickable?RENDER_PASSES.PICK:RENDER_PASSES.NOT_RENDERED;var clippableFlag=!!(flags&ENTITY_FLAGS.CLIPPABLE)?
|
|
15700
|
+
*/},{key:"_setFlags",value:function _setFlags(portionId,flags,meshTransparent){if(!this._finalized){throw"Not finalized";}var visible=!!(flags&ENTITY_FLAGS.VISIBLE);var xrayed=!!(flags&ENTITY_FLAGS.XRAYED);var highlighted=!!(flags&ENTITY_FLAGS.HIGHLIGHTED);var selected=!!(flags&ENTITY_FLAGS.SELECTED);var edges=!!(flags&ENTITY_FLAGS.EDGES);var pickable=!!(flags&ENTITY_FLAGS.PICKABLE);var culled=!!(flags&ENTITY_FLAGS.CULLED);var colorFlag;if(!visible||culled||xrayed||highlighted&&!this.model.scene.highlightMaterial.glowThrough||selected&&!this.model.scene.selectedMaterial.glowThrough){colorFlag=RENDER_PASSES.NOT_RENDERED;}else{if(meshTransparent){colorFlag=RENDER_PASSES.COLOR_TRANSPARENT;}else{colorFlag=RENDER_PASSES.COLOR_OPAQUE;}}var silhouetteFlag;if(!visible||culled){silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){silhouetteFlag=RENDER_PASSES.SILHOUETTE_SELECTED;}else if(highlighted){silhouetteFlag=RENDER_PASSES.SILHOUETTE_HIGHLIGHTED;}else if(xrayed){silhouetteFlag=RENDER_PASSES.SILHOUETTE_XRAYED;}else{silhouetteFlag=RENDER_PASSES.NOT_RENDERED;}var edgeFlag=0;if(!visible||culled){edgeFlag=RENDER_PASSES.NOT_RENDERED;}else if(selected){edgeFlag=RENDER_PASSES.EDGES_SELECTED;}else if(highlighted){edgeFlag=RENDER_PASSES.EDGES_HIGHLIGHTED;}else if(xrayed){edgeFlag=RENDER_PASSES.EDGES_XRAYED;}else if(edges){if(meshTransparent){edgeFlag=RENDER_PASSES.EDGES_COLOR_TRANSPARENT;}else{edgeFlag=RENDER_PASSES.EDGES_COLOR_OPAQUE;}}else{edgeFlag=RENDER_PASSES.NOT_RENDERED;}var pickFlag=visible&&!culled&&pickable?RENDER_PASSES.PICK:RENDER_PASSES.NOT_RENDERED;var clippableFlag=!!(flags&ENTITY_FLAGS.CLIPPABLE)?1:0;var vertFlag=0;vertFlag|=colorFlag;vertFlag|=silhouetteFlag<<4;vertFlag|=edgeFlag<<8;vertFlag|=pickFlag<<12;vertFlag|=clippableFlag<<16;tempFloat32$1[0]=vertFlag;this._state.flagsBuf.setData(tempFloat32$1,portionId);}},{key:"setOffset",value:function setOffset(portionId,offset){if(!this._finalized){throw"Not finalized";}if(!this.model.scene.entityOffsetsEnabled){this.model.error("Entity#offset not enabled for this Viewer");// See Viewer entityOffsetsEnabled
|
|
15676
15701
|
return;}tempVec3fa$1[0]=offset[0];tempVec3fa$1[1]=offset[1];tempVec3fa$1[2]=offset[2];this._state.offsetsBuf.setData(tempVec3fa$1,portionId*3,3);}},{key:"setMatrix",value:function setMatrix(portionId,matrix){////////////////////////////////////////
|
|
15677
15702
|
// TODO: Update portion matrix
|
|
15678
15703
|
////////////////////////////////////////
|
|
@@ -16912,7 +16937,7 @@ Math.floor(subPortionId/512),// yoffset
|
|
|
16912
16937
|
4,// width
|
|
16913
16938
|
1,// height
|
|
16914
16939
|
gl.RGBA,gl.FLOAT,tempMat4a);// gl.bindTexture (gl.TEXTURE_2D, null);
|
|
16915
|
-
}},{key:"getEachVertex",value:function getEachVertex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return;}var state=this._state;var subPortionIds=this._portionToSubPortionsMap[portionId];if(!subPortionIds){this.model.error("portion not found: "+portionId);return;}for(var _i384=0,len=subPortionIds.length;_i384<len;_i384++){var subPortionId=subPortionIds[_i384];var subPortionReadableGeometry=this._subPortionReadableGeometries[subPortionId];var positions=subPortionReadableGeometry.positionsCompressed;var positionsDecodeMatrix=subPortionReadableGeometry.positionsDecodeMatrix;subPortionReadableGeometry.meshMatrix;var origin=state.origin;var offsetX=origin[0];var offsetY=origin[1];var offsetZ=origin[2];var worldPos=tempVec4a$6;for(var _i385=0,_len76=positions.length;_i385<_len76;_i385+=3){worldPos[0]=positions[_i385];worldPos[1]=positions[_i385+1];worldPos[2]=positions[_i385+2];worldPos[3]=1.0;math.decompressPosition(worldPos,positionsDecodeMatrix);math.
|
|
16940
|
+
}},{key:"getEachVertex",value:function getEachVertex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return;}var state=this._state;var subPortionIds=this._portionToSubPortionsMap[portionId];if(!subPortionIds){this.model.error("portion not found: "+portionId);return;}for(var _i384=0,len=subPortionIds.length;_i384<len;_i384++){var subPortionId=subPortionIds[_i384];var subPortionReadableGeometry=this._subPortionReadableGeometries[subPortionId];var positions=subPortionReadableGeometry.positionsCompressed;var positionsDecodeMatrix=subPortionReadableGeometry.positionsDecodeMatrix;subPortionReadableGeometry.meshMatrix;var origin=state.origin;var offsetX=origin[0];var offsetY=origin[1];var offsetZ=origin[2];var worldPos=tempVec4a$6;for(var _i385=0,_len76=positions.length;_i385<_len76;_i385+=3){worldPos[0]=positions[_i385];worldPos[1]=positions[_i385+1];worldPos[2]=positions[_i385+2];worldPos[3]=1.0;math.decompressPosition(worldPos,positionsDecodeMatrix);math.mulMat4v4(this.model.worldMatrix,worldPos,worldPos);worldPos[0]+=offsetX;worldPos[1]+=offsetY;worldPos[2]+=offsetZ;callback(worldPos);}}}},{key:"getEachIndex",value:function getEachIndex(portionId,callback){if(!this.model.scene.readableGeometryEnabled){return;}var subPortionIds=this._portionToSubPortionsMap[portionId];if(!subPortionIds){this.model.error("portion not found: "+portionId);return;}for(var _i386=0,len=subPortionIds.length;_i386<len;_i386++){var subPortionId=subPortionIds[_i386];var subPortionReadableGeometry=this._subPortionReadableGeometries[subPortionId];var indices=subPortionReadableGeometry.indices;for(var _i387=0,_len77=indices.length;_i387<_len77;_i387++){callback(indices[_i387]);}}}// ---------------------- COLOR RENDERING -----------------------------------
|
|
16916
16941
|
},{key:"drawColorOpaque",value:function drawColorOpaque(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===this._numPortions||this._numXRayedLayerPortions===this._numPortions){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(frameCtx.withSAO&&this.model.saoEnabled){if(this._renderers.colorRendererWithSAO){this._renderers.colorRendererWithSAO.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}else{if(this._renderers.colorRenderer){this._renderers.colorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}}},{key:"_updateBackfaceCull",value:function _updateBackfaceCull(renderFlags,frameCtx){var backfaces=this.model.backfaces||renderFlags.sectioned;if(frameCtx.backfaces!==backfaces){var _gl6=frameCtx.gl;if(backfaces){_gl6.disable(_gl6.CULL_FACE);}else{_gl6.enable(_gl6.CULL_FACE);}frameCtx.backfaces=backfaces;}}},{key:"drawColorTransparent",value:function drawColorTransparent(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===0||this._numXRayedLayerPortions===this._numPortions){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._renderers.colorRenderer){this._renderers.colorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_TRANSPARENT);}}// ---------------------- RENDERING SAO POST EFFECT TARGETS --------------
|
|
16917
16942
|
},{key:"drawDepth",value:function drawDepth(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===this._numPortions||this._numXRayedLayerPortions===this._numPortions){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._renderers.depthRenderer){this._renderers.depthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);// Assume whatever post-effect uses depth (eg SAO) does not apply to transparent objects
|
|
16918
16943
|
}}},{key:"drawNormals",value:function drawNormals(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===this._numPortions||this._numXRayedLayerPortions===this._numPortions){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._renderers.normalsRenderer){this._renderers.normalsRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);// Assume whatever post-effect uses normals (eg SAO) does not apply to transparent objects
|
|
@@ -16977,7 +17002,7 @@ gl.RGBA,gl.FLOAT,tempMat4a);// gl.bindTexture (gl.TEXTURE_2D, null);
|
|
|
16977
17002
|
*/_createClass(SceneModelTexture,[{key:"destroy",value:function destroy(){if(this.texture){this.texture.destroy();this.texture=null;}}}]);return SceneModelTexture;}();var Cache$1={enabled:false,files:{},add:function add(key,file){if(this.enabled===false){return;}this.files[key]=file;},get:function get(key){if(this.enabled===false){return;}return this.files[key];},remove:function remove(key){delete this.files[key];},clear:function clear(){this.files={};}};var LoadingManager=/*#__PURE__*/function(){function LoadingManager(onLoad,onProgress,onError){_classCallCheck(this,LoadingManager);this.isLoading=false;this.itemsLoaded=0;this.itemsTotal=0;this.urlModifier=undefined;this.handlers=[];this.onStart=undefined;this.onLoad=onLoad;this.onProgress=onProgress;this.onError=onError;}_createClass(LoadingManager,[{key:"itemStart",value:function itemStart(url){this.itemsTotal++;if(this.isLoading===false){if(this.onStart!==undefined){this.onStart(url,this.itemsLoaded,this.itemsTotal);}}this.isLoading=true;}},{key:"itemEnd",value:function itemEnd(url){this.itemsLoaded++;if(this.onProgress!==undefined){this.onProgress(url,this.itemsLoaded,this.itemsTotal);}if(this.itemsLoaded===this.itemsTotal){this.isLoading=false;if(this.onLoad!==undefined){this.onLoad();}}}},{key:"itemError",value:function itemError(url){if(this.onError!==undefined){this.onError(url);}}},{key:"resolveURL",value:function resolveURL(url){if(this.urlModifier){return this.urlModifier(url);}return url;}},{key:"setURLModifier",value:function setURLModifier(transform){this.urlModifier=transform;return this;}},{key:"addHandler",value:function addHandler(regex,loader){this.handlers.push(regex,loader);return this;}},{key:"removeHandler",value:function removeHandler(regex){var index=this.handlers.indexOf(regex);if(index!==-1){this.handlers.splice(index,2);}return this;}},{key:"getHandler",value:function getHandler(file){for(var _i388=0,_l3=this.handlers.length;_i388<_l3;_i388+=2){var regex=this.handlers[_i388];var loader=this.handlers[_i388+1];if(regex.global)regex.lastIndex=0;// see #17920
|
|
16978
17003
|
if(regex.test(file)){return loader;}}return null;}}]);return LoadingManager;}();var DefaultLoadingManager=new LoadingManager();var Loader=/*#__PURE__*/function(){function Loader(manager){_classCallCheck(this,Loader);this.manager=manager!==undefined?manager:DefaultLoadingManager;this.crossOrigin='anonymous';this.withCredentials=false;this.path='';this.resourcePath='';this.requestHeader={};}_createClass(Loader,[{key:"load",value:function/* url, onLoad, onProgress, onError */load(){}},{key:"loadAsync",value:function loadAsync(url,onProgress){var scope=this;return new Promise(function(resolve,reject){scope.load(url,resolve,onProgress,reject);});}},{key:"parse",value:function/* data */parse(){}},{key:"setCrossOrigin",value:function setCrossOrigin(crossOrigin){this.crossOrigin=crossOrigin;return this;}},{key:"setWithCredentials",value:function setWithCredentials(value){this.withCredentials=value;return this;}},{key:"setPath",value:function setPath(path){this.path=path;return this;}},{key:"setResourcePath",value:function setResourcePath(resourcePath){this.resourcePath=resourcePath;return this;}},{key:"setRequestHeader",value:function setRequestHeader(requestHeader){this.requestHeader=requestHeader;return this;}}]);return Loader;}();var loading={};var FileLoader=/*#__PURE__*/function(_Loader){_inherits(FileLoader,_Loader);var _super117=_createSuper(FileLoader);function FileLoader(manager){_classCallCheck(this,FileLoader);return _super117.call(this,manager);}_createClass(FileLoader,[{key:"load",value:function load(url,onLoad,onProgress,onError){var _this79=this;if(url===undefined){url='';}if(this.path!==undefined){url=this.path+url;}url=this.manager.resolveURL(url);var cached=Cache$1.get(url);if(cached!==undefined){this.manager.itemStart(url);core.scheduleTask(function(){if(onLoad){onLoad(cached);}_this79.manager.itemEnd(url);},0);return cached;}if(loading[url]!==undefined){loading[url].push({onLoad:onLoad,onProgress:onProgress,onError:onError});return;}loading[url]=[];loading[url].push({onLoad:onLoad,onProgress:onProgress,onError:onError});var req=new Request(url,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?'include':'same-origin'});var mimeType=this.mimeType;var responseType=this.responseType;fetch(req).then(function(response){if(response.status===200||response.status===0){// Some browsers return HTTP Status 0 when using non-http protocol
|
|
16979
17004
|
// e.g. 'file://' or 'data://'. Handle as success.
|
|
16980
|
-
if(response.status===0){console.warn('FileLoader: HTTP Status 0 received.');}if(typeof ReadableStream==='undefined'||response.body.getReader===undefined){return response;}var callbacks=loading[url];var reader=response.body.getReader();var contentLength=response.headers.get('Content-Length');var total=contentLength?parseInt(contentLength):0;var lengthComputable=total!==0;var loaded=0;var stream=new ReadableStream({start:function start(controller){readData();function readData(){reader.read().then(function(
|
|
17005
|
+
if(response.status===0){console.warn('FileLoader: HTTP Status 0 received.');}if(typeof ReadableStream==='undefined'||response.body.getReader===undefined){return response;}var callbacks=loading[url];var reader=response.body.getReader();var contentLength=response.headers.get('Content-Length');var total=contentLength?parseInt(contentLength):0;var lengthComputable=total!==0;var loaded=0;var stream=new ReadableStream({start:function start(controller){readData();function readData(){reader.read().then(function(_ref12){var done=_ref12.done,value=_ref12.value;if(done){controller.close();}else{loaded+=value.byteLength;var event=new ProgressEvent('progress',{lengthComputable:lengthComputable,loaded:loaded,total:total});for(var _i389=0,il=callbacks.length;_i389<il;_i389++){var callback=callbacks[_i389];if(callback.onProgress){callback.onProgress(event);}}controller.enqueue(value);readData();}});}}});return new Response(stream);}else{throw Error("fetch for \"".concat(response.url,"\" responded with ").concat(response.status,": ").concat(response.statusText));}}).then(function(response){switch(responseType){case'arraybuffer':return response.arrayBuffer();case'blob':return response.blob();case'document':return response.text().then(function(text){var parser=new DOMParser();return parser.parseFromString(text,mimeType);});case'json':return response.json();default:if(mimeType===undefined){return response.text();}else{// sniff encoding
|
|
16981
17006
|
var re=/charset="?([^;"\s]*)"?/i;var exec=re.exec(mimeType);var label=exec&&exec[1]?exec[1].toLowerCase():undefined;var decoder=new TextDecoder(label);return response.arrayBuffer().then(function(ab){return decoder.decode(ab);});}}}).then(function(data){// Add to cache only on HTTP success, so that we do not cache
|
|
16982
17007
|
// error response bodies as proper responses to requests.
|
|
16983
17008
|
Cache$1.add(url,data);var callbacks=loading[url];delete loading[url];for(var _i390=0,il=callbacks.length;_i390<il;_i390++){var callback=callbacks[_i390];if(callback.onLoad){callback.onLoad(data);}}})["catch"](function(err){// Abort errors and other errors are handled the same
|
|
@@ -17200,7 +17225,7 @@ _this79.manager.itemError(url);throw err;}delete loading[url];for(var _i391=0,il
|
|
|
17200
17225
|
* then our KTX2TextureTranscoder will load it from ````https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/```` by
|
|
17201
17226
|
* default. Therefore, make sure your application is connected to the internet if you wish to use the default transcoder path.
|
|
17202
17227
|
* @param {Number} [workerLimit] The maximum number of Workers to use for transcoding.
|
|
17203
|
-
*/function KTX2TextureTranscoder(
|
|
17228
|
+
*/function KTX2TextureTranscoder(_ref13){var viewer=_ref13.viewer,transcoderPath=_ref13.transcoderPath,workerLimit=_ref13.workerLimit;_classCallCheck(this,KTX2TextureTranscoder);this._transcoderPath=transcoderPath||"https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/basis/";this._transcoderBinary=null;this._transcoderPending=null;this._workerPool=new WorkerPool$1();this._workerSourceURL='';if(workerLimit){this._workerPool.setWorkerLimit(workerLimit);}var viewerCapabilities=viewer.capabilities;this._workerConfig={astcSupported:viewerCapabilities.astcSupported,etc1Supported:viewerCapabilities.etc1Supported,etc2Supported:viewerCapabilities.etc2Supported,dxtSupported:viewerCapabilities.dxtSupported,bptcSupported:viewerCapabilities.bptcSupported,pvrtcSupported:viewerCapabilities.pvrtcSupported};this._supportedFileTypes=["xkt2"];}_createClass(KTX2TextureTranscoder,[{key:"_init",value:function _init(){var _this81=this;if(!this._transcoderPending){var jsLoader=new FileLoader();jsLoader.setPath(this._transcoderPath);jsLoader.setWithCredentials(this.withCredentials);var jsContent=jsLoader.loadAsync('basis_transcoder.js');var binaryLoader=new FileLoader();binaryLoader.setPath(this._transcoderPath);binaryLoader.setResponseType('arraybuffer');binaryLoader.setWithCredentials(this.withCredentials);var binaryContent=binaryLoader.loadAsync('basis_transcoder.wasm');this._transcoderPending=Promise.all([jsContent,binaryContent]).then(function(_ref14){var _ref15=_slicedToArray(_ref14,2),jsContent=_ref15[0],binaryContent=_ref15[1];var fn=KTX2TextureTranscoder.BasisWorker.toString();var body=['/* constants */','let _EngineFormat = '+JSON.stringify(KTX2TextureTranscoder.EngineFormat),'let _TranscoderFormat = '+JSON.stringify(KTX2TextureTranscoder.TranscoderFormat),'let _BasisFormat = '+JSON.stringify(KTX2TextureTranscoder.BasisFormat),'/* basis_transcoder.js */',jsContent,'/* worker */',fn.substring(fn.indexOf('{')+1,fn.lastIndexOf('}'))].join('\n');_this81._workerSourceURL=URL.createObjectURL(new Blob([body]));_this81._transcoderBinary=binaryContent;_this81._workerPool.setWorkerCreator(function(){var worker=new Worker(_this81._workerSourceURL);var transcoderBinary=_this81._transcoderBinary.slice(0);worker.postMessage({type:'init',config:_this81._workerConfig,transcoderBinary:transcoderBinary},[transcoderBinary]);return worker;});});if(activeTranscoders>0){console.warn('KTX2TextureTranscoder: Multiple active KTX2TextureTranscoder may cause performance issues.'+' Use a single KTX2TextureTranscoder instance, or call .dispose() on old instances.');}activeTranscoders++;}return this._transcoderPending;}/**
|
|
17204
17229
|
* Transcodes texture data from transcoded buffers into a {@link Texture2D}.
|
|
17205
17230
|
*
|
|
17206
17231
|
* @param {ArrayBuffer[]} buffers Transcoded texture data. Given as an array of buffers so that we can support multi-image textures, such as cube maps.
|
|
@@ -18635,7 +18660,7 @@ var defaultColorTexture=new SceneModelTexture({id:DEFAULT_COLOR_TEXTURE_ID,textu
|
|
|
18635
18660
|
* Gets the SceneModel's local modeling rotation transform matrix.
|
|
18636
18661
|
*
|
|
18637
18662
|
* @type {Number[]}
|
|
18638
|
-
*/,set:function set(value){this._matrix.set(value||DEFAULT_MATRIX);math.decomposeMat4(this._matrix,this._position,this._quaternion,this._scale);this._matrixDirty=false;this._setWorldMatrixDirty();this._sceneModelDirty();this.glRedraw();}},{key:"rotationMatrix",get:function get(){this._rebuildMatrices();return this._worldRotationMatrix;}},{key:"_rebuildMatrices",value:function _rebuildMatrices(){if(this._matrixDirty){math.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix);math.conjugateQuaternion(this._quaternion,this._conjugateQuaternion);math.quaternionToRotationMat4(this._conjugateQuaternion,this._worldRotationMatrixConjugate);math.scaleMat4v(this._scale,this._worldRotationMatrix);math.scaleMat4v(this._scale,this._worldRotationMatrixConjugate);this._matrix.set(this._worldRotationMatrix);math.translateMat4v(this._position,this._matrix);this._matrixDirty=false;this._viewMatrixDirty=true;}}/**
|
|
18663
|
+
*/,set:function set(value){this._matrix.set(value||DEFAULT_MATRIX);math.decomposeMat4(this._matrix,this._position,this._quaternion,this._scale);math.quaternionToEuler(this._quaternion,"XYZ",this._rotation);this._matrixDirty=false;this._setWorldMatrixDirty();this._sceneModelDirty();this.glRedraw();}},{key:"rotationMatrix",get:function get(){this._rebuildMatrices();return this._worldRotationMatrix;}},{key:"_rebuildMatrices",value:function _rebuildMatrices(){if(this._matrixDirty){math.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix);math.conjugateQuaternion(this._quaternion,this._conjugateQuaternion);math.quaternionToRotationMat4(this._conjugateQuaternion,this._worldRotationMatrixConjugate);math.scaleMat4v(this._scale,this._worldRotationMatrix);math.scaleMat4v(this._scale,this._worldRotationMatrixConjugate);this._matrix.set(this._worldRotationMatrix);math.translateMat4v(this._position,this._matrix);this._matrixDirty=false;this._viewMatrixDirty=true;}}/**
|
|
18639
18664
|
* Gets the conjugate of the SceneModel's local modeling rotation transform matrix.
|
|
18640
18665
|
*
|
|
18641
18666
|
* This is used for RTC view matrix management in renderers.
|
|
@@ -19619,10 +19644,10 @@ lookDirection=YToZ(lookDirection);eye=YToZ(eye);up=YToZ(up);}var camera_view_poi
|
|
|
19619
19644
|
var sectionPlanes=scene.sectionPlanes;for(var id in sectionPlanes){if(sectionPlanes.hasOwnProperty(id)){var sectionPlane=sectionPlanes[id];if(!sectionPlane.active){continue;}var location=sectionPlane.pos;var _direction=void 0;if(reverseClippingPlanes){_direction=math.negateVec3(sectionPlane.dir,math.vec3());}else{_direction=sectionPlane.dir;}if(camera.yUp){// BCF is Z up
|
|
19620
19645
|
location=YToZ(location);_direction=YToZ(_direction);}math.addVec3(location,realWorldOffset);location=xyzArrayToObject(location);_direction=xyzArrayToObject(_direction);if(!bcfViewpoint.clipping_planes){bcfViewpoint.clipping_planes=[];}bcfViewpoint.clipping_planes.push({location:location,direction:_direction});}}// Lines
|
|
19621
19646
|
var lineSets=scene.lineSets;for(var _id2 in lineSets){if(lineSets.hasOwnProperty(_id2)){var lineSet=lineSets[_id2];if(!bcfViewpoint.lines){bcfViewpoint.lines=[];}var positions=lineSet.positions;var indices=lineSet.indices;for(var _i464=0,len=indices.length/2;_i464<len;_i464++){var _a5=indices[_i464*2];var b=indices[_i464*2+1];bcfViewpoint.lines.push({start_point:{x:positions[_a5*3+0],y:positions[_a5*3+1],z:positions[_a5*3+2]},end_point:{x:positions[b*3+0],y:positions[b*3+1],z:positions[b*3+2]}});}}}// Bitmaps
|
|
19622
|
-
var bitmaps=scene.bitmaps;for(var _id3 in bitmaps){if(bitmaps.hasOwnProperty(_id3)){var bitmap=bitmaps[_id3];var _location=bitmap.pos;var normal=bitmap.normal;var
|
|
19623
|
-
_location=YToZ(_location);normal=YToZ(normal);
|
|
19647
|
+
var bitmaps=scene.bitmaps;for(var _id3 in bitmaps){if(bitmaps.hasOwnProperty(_id3)){var bitmap=bitmaps[_id3];var _location=bitmap.pos;var normal=bitmap.normal;var _up2=bitmap.up;if(camera.yUp){// BCF is Z up
|
|
19648
|
+
_location=YToZ(_location);normal=YToZ(normal);_up2=YToZ(_up2);}math.addVec3(_location,realWorldOffset);if(!bcfViewpoint.bitmaps){bcfViewpoint.bitmaps=[];}bcfViewpoint.bitmaps.push({bitmap_type:bitmap.type,bitmap_data:bitmap.imageData,location:xyzArrayToObject(_location),normal:xyzArrayToObject(normal),up:xyzArrayToObject(_up2),height:bitmap.height});}}// Entity states
|
|
19624
19649
|
bcfViewpoint.components={visibility:{view_setup_hints:{spaces_visible:!!options.spacesVisible,space_boundaries_visible:!!options.spaceBoundariesVisible,openings_visible:!!options.openingsVisible,spaces_translucent:!!options.spaces_translucent,space_boundaries_translucent:!!options.space_boundaries_translucent,openings_translucent:!!options.openings_translucent}}};var opacityObjectIds=new Set(scene.opacityObjectIds);var xrayedObjectIds=new Set(scene.xrayedObjectIds);var colorizedObjectIds=new Set(scene.colorizedObjectIds);var coloringMap=Object.values(scene.objects).filter(function(entity){return opacityObjectIds.has(entity.id)||colorizedObjectIds.has(entity.id)||xrayedObjectIds.has(entity.id);}).reduce(function(coloringMap,entity){var color=colorizeToRGB(entity.colorize);var alpha;if(entity.xrayed){if(scene.xrayMaterial.fillAlpha===0.0&&scene.xrayMaterial.edgeAlpha!==0.0){// BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
|
|
19625
|
-
alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this87.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(
|
|
19650
|
+
alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this87.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(_ref16){var _ref17=_slicedToArray(_ref16,2),color=_ref17[0],components=_ref17[1];return{color:color,components:components};});bcfViewpoint.components.coloring=coloringArray;var objectIds=scene.objectIds;var visibleObjects=scene.visibleObjects;var visibleObjectIds=scene.visibleObjectIds;var invisibleObjectIds=objectIds.filter(function(id){return!visibleObjects[id];});var selectedObjectIds=scene.selectedObjectIds;if(options.defaultInvisible||visibleObjectIds.length<invisibleObjectIds.length){bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(visibleObjectIds);bcfViewpoint.components.visibility.default_visibility=false;}else{bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(invisibleObjectIds);bcfViewpoint.components.visibility.default_visibility=true;}bcfViewpoint.components.selection=this._createBCFComponents(selectedObjectIds);bcfViewpoint.components.translucency=this._createBCFComponents(scene.xrayedObjectIds);if(options.snapshot!==false){bcfViewpoint.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})};}return bcfViewpoint;}},{key:"_createBCFComponents",value:function _createBCFComponents(objectIds){var scene=this.viewer.scene;var components=[];for(var _i465=0,len=objectIds.length;_i465<len;_i465++){var objectId=objectIds[_i465];var entity=scene.objects[objectId];if(entity){var component={ifc_guid:entity.originalSystemId,originating_system:this.originatingSystem};if(entity.originalSystemId!==objectId){component.authoring_tool_id=objectId;}components.push(component);}}return components;}/**
|
|
19626
19651
|
* Sets viewer state to the given BCF viewpoint.
|
|
19627
19652
|
*
|
|
19628
19653
|
* Note that xeokit's {@link Camera#look} is the **point-of-interest**, whereas the BCF ````camera_direction```` is a
|
|
@@ -19646,8 +19671,8 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).
|
|
|
19646
19671
|
* then this method will apply the updates to objects within those composites.
|
|
19647
19672
|
*/},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this88=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var _i466=0;bcfViewpoint.lines.forEach(function(e){if(!e.start_point){return;}if(!e.end_point){return;}positions.push(e.start_point.x);positions.push(e.start_point.y);positions.push(e.start_point.z);positions.push(e.end_point.x);positions.push(e.end_point.y);positions.push(e.end_point.z);indices.push(_i466++);indices.push(_i466++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps&&bcfViewpoint.bitmaps.length>0){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
|
|
19648
19673
|
var bitmap_data=e.bitmap_data;// base64
|
|
19649
|
-
var location=xyzObjectToArray(e.location,tempVec3a$9);var normal=xyzObjectToArray(e.normal,tempVec3b$6);var up=xyzObjectToArray(e.up,tempVec3c$4);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.spaces_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.space_boundaries_visible!==undefined);if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}if(view_setup_hints.space_boundaries_translucent!==undefined);if(view_setup_hints.openings_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.translucency){scene.setObjectsXRayed(scene.xrayedObjectIds,false);bcfViewpoint.components.translucency.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.xrayed=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this88._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var
|
|
19650
|
-
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=
|
|
19674
|
+
var location=xyzObjectToArray(e.location,tempVec3a$9);var normal=xyzObjectToArray(e.normal,tempVec3b$6);var up=xyzObjectToArray(e.up,tempVec3c$4);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.spaces_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.space_boundaries_visible!==undefined);if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}if(view_setup_hints.space_boundaries_translucent!==undefined);if(view_setup_hints.openings_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.translucency){scene.setObjectsXRayed(scene.xrayedObjectIds,false);bcfViewpoint.components.translucency.forEach(function(component){return _this88._withBCFComponent(options,component,function(entity){return entity.xrayed=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this88._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var _up3;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);_up3=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);_up3=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);_up3=ZToY(_up3);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
|
|
19675
|
+
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=_up3;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:_up3,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity2=scene.objects[originalSystemId];if(_entity2){callback(_entity2);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
|
|
19651
19676
|
* Destroys this BCFViewpointsPlugin.
|
|
19652
19677
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var tmpVec3a=math.vec3();var tmpVec3b=math.vec3();var tmpVec3c=math.vec3();math.vec4();math.vec4();math.vec4();/**
|
|
19653
19678
|
* @desc Measures the distance between two 3D points.
|
|
@@ -20370,7 +20395,7 @@ origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3
|
|
|
20370
20395
|
* Destroys this DistanceMeasurementsPlugin.
|
|
20371
20396
|
*
|
|
20372
20397
|
* Destroys all {@link DistanceMeasurement}s first.
|
|
20373
|
-
*/},{key:"destroy",value:function destroy(){this.clear();_get(_getPrototypeOf(DistanceMeasurementsPlugin.prototype),"destroy",this).call(this);}}]);return DistanceMeasurementsPlugin;}(Plugin);var WAITING_FOR_ORIGIN_TOUCH_START=0;var WAITING_FOR_ORIGIN_QUICK_TOUCH_END=1;var WAITING_FOR_ORIGIN_LONG_TOUCH_END=2;var WAITING_FOR_TARGET_TOUCH_START=3;var WAITING_FOR_TARGET_QUICK_TOUCH_END=4;var WAITING_FOR_TARGET_LONG_TOUCH_END=5;var TOUCH_CANCELING=7;/**
|
|
20398
|
+
*/},{key:"destroy",value:function destroy(){this.clear();_get(_getPrototypeOf(DistanceMeasurementsPlugin.prototype),"destroy",this).call(this);}}]);return DistanceMeasurementsPlugin;}(Plugin);var WAITING_FOR_ORIGIN_TOUCH_START=0;var WAITING_FOR_ORIGIN_QUICK_TOUCH_END=1;var WAITING_FOR_ORIGIN_LONG_TOUCH_END=2;var WAITING_FOR_TARGET_TOUCH_START=3;var WAITING_FOR_TARGET_QUICK_TOUCH_END=4;var WAITING_FOR_TARGET_LONG_TOUCH_END=5;var TOUCH_CANCELING=7;var tmpVec2=math.vec2();/**
|
|
20374
20399
|
* Creates {@link DistanceMeasurement}s from touch input.
|
|
20375
20400
|
*
|
|
20376
20401
|
* See {@link DistanceMeasurementsPlugin} for more info.
|
|
@@ -20400,10 +20425,8 @@ origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3
|
|
|
20400
20425
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
20401
20426
|
*/function get(){return this._snapping;}/**
|
|
20402
20427
|
* Activates this DistanceMeasurementsTouchControl, ready to respond to input.
|
|
20403
|
-
*/,set:function set(snapping){this._snapping=snapping;}},{key:"activate",value:function activate(){var _this97=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this97.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this97.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement.destroy();_this97._currentDistanceMeasurement=null;}enableCameraNavigation();_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0]
|
|
20404
|
-
var
|
|
20405
|
-
var touchX=touch.clientX-rect.left;var touchY=touch.clientY-rect.top;touchStartCanvasPos.set([touchX,touchY]);touchMoveCanvasPos.set([touchX,touchY]);switch(_this97._touchState){case WAITING_FOR_ORIGIN_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
20406
|
-
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapping:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this97.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this97.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
20428
|
+
*/,set:function set(snapping){this._snapping=snapping;}},{key:"activate",value:function activate(){var _this97=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this97.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this97.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement.destroy();_this97._currentDistanceMeasurement=null;}enableCameraNavigation();_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;};var copyCanvasPos=function copyCanvasPos(event,dst){dst[0]=event.clientX;dst[1]=event.clientY;transformToNode(canvas.ownerDocument.documentElement,canvas,dst);return dst;};var toBodyPos=function toBodyPos(pos,dst){dst.set(pos);transformToNode(canvas,canvas.ownerDocument.documentElement,dst);return dst;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];copyCanvasPos(touch,touchStartCanvasPos);touchMoveCanvasPos.set(touchStartCanvasPos);switch(_this97._touchState){case WAITING_FOR_ORIGIN_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
20429
|
+
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapping:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this97.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos,tmpVec2));}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this97.pointerCircle.start(toBodyPos(pickResult.canvasPos,tmpVec2));}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
20407
20430
|
}// Long touch
|
|
20408
20431
|
if(_this97.pointerLens){_this97.pointerLens.visible=true;_this97.pointerLens.canvasPos=touchStartCanvasPos;_this97.pointerLens.cursorPos=touchStartCanvasPos;}if(_this97.pointerLens){_this97.pointerLens.canvasPos=touchMoveCanvasPos;_this97.pointerLens.snapped=false;}if(_this97.pointerLens){_this97.pointerLens.cursorPos=snapPickResult.canvasPos;_this97.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.snappedWorldPos);
|
|
20409
20432
|
if(!_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos,entity:snapPickResult.entity},target:{worldPos:pointerWorldPos,entity:snapPickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;}else{_this97._currentDistanceMeasurement.origin.worldPos=pointerWorldPos;}_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);// if (this.pointerLens) {
|
|
@@ -20416,21 +20439,17 @@ touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START:if(currentNum
|
|
|
20416
20439
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
20417
20440
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
20418
20441
|
return;}// Long touch
|
|
20419
|
-
if(_this97.pointerLens){_this97.pointerLens.visible=true;_this97.pointerLens.canvasPos=touchStartCanvasPos;_this97.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this97.pointerLens){_this97.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}_this97.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this97._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=_pickResult6.canvasPos;_this97.pointerLens.snapped=false;}_this97.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this97._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this97._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{if(_this97.pointerLens){_this97.pointerLens.cursorPos=null;_this97.pointerLens.snapped=false;}}}_this97._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
20442
|
+
if(_this97.pointerLens){_this97.pointerLens.visible=true;_this97.pointerLens.canvasPos=touchStartCanvasPos;_this97.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this97.pointerLens){_this97.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}_this97.pointerCircle.start(toBodyPos(snapPickResult.snappedCanvasPos,tmpVec2));pointerWorldPos.set(snapPickResult.worldPos);_this97._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=_pickResult6.canvasPos;_this97.pointerLens.snapped=false;}_this97.pointerCircle.start(toBodyPos(_pickResult6.canvasPos,tmpVec2));pointerWorldPos.set(_pickResult6.worldPos);_this97._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this97._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{if(_this97.pointerLens){_this97.pointerLens.cursorPos=null;_this97.pointerLens.snapped=false;}}}_this97._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
20420
20443
|
disableCameraNavigation();},_this97._longTouchTimeoutMs);_this97._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
20421
20444
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this97._touchState=TOUCH_CANCELING;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
20422
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this97.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];//
|
|
20423
|
-
var rect=canvas.getBoundingClientRect();// Calculate the touch position relative to the canvas
|
|
20424
|
-
var touchX=touch.clientX-rect.left;var touchY=touch.clientY-rect.top;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this97._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this97.pointerLens){_this97.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this97.pointerLens){_this97.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;}else{_this97._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=pickResult.canvasPos;_this97.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;}else{_this97._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{if(_this97.pointerLens){_this97.pointerLens.cursorPos=null;_this97.pointerLens.snapped=false;}}}_this97._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
20445
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this97.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];if(touch.identifier!==touchId){return;}copyCanvasPos(touch,touchMoveCanvasPos);var snapPickResult;var pickResult;switch(_this97._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this97.pointerLens){_this97.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this97.pointerLens){_this97.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;}else{_this97._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=pickResult.canvasPos;_this97.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;}else{_this97._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);}else{if(_this97.pointerLens){_this97.pointerLens.cursorPos=null;_this97.pointerLens.snapped=false;}}}_this97._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
20425
20446
|
break;// case WAITING_FOR_TARGET_TOUCH_START:
|
|
20426
20447
|
// this._touchState = WAITING_FOR_TARGET_TOUCH_START;
|
|
20427
20448
|
// console.log("touchmove: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_TOUCH_START")
|
|
20428
20449
|
// break;
|
|
20429
20450
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
20430
20451
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this97.pointerLens){_this97.pointerLens.visible=false;}_this97._touchState=TOUCH_CANCELING;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
20431
|
-
return;}if(_this97.pointerLens){_this97.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}_this97._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=pickResult.canvasPos;_this97.pointerLens.snapped=false;}_this97._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=pickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;}}_this97._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this97.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];//
|
|
20432
|
-
var rect=canvas.getBoundingClientRect();// Calculate the touch position relative to the canvas
|
|
20433
|
-
var touchX=touch.clientX-rect.left;var touchY=touch.clientY-rect.top;if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}touchEndCanvasPos.set([touchX,touchY]);switch(_this97._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;_this97._touchState=WAITING_FOR_TARGET_TOUCH_START;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
20452
|
+
return;}if(_this97.pointerLens){_this97.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this97._snapping,snapToEdge:_this97._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this97.pointerLens.snapped=true;}_this97._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this97.pointerLens){_this97.pointerLens.cursorPos=pickResult.canvasPos;_this97.pointerLens.snapped=false;}_this97._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this97._currentDistanceMeasurement.target.entity=pickResult.entity;_this97._currentDistanceMeasurement.targetVisible=true;_this97._currentDistanceMeasurement.wireVisible=true;_this97._currentDistanceMeasurement.labelsVisible=true;}}_this97._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this97.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}copyCanvasPos(touch,touchEndCanvasPos);var touchX=touchEndCanvasPos[0];var touchY=touchEndCanvasPos[1];switch(_this97._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this97._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this97._currentDistanceMeasurement.labelsVisible=false;_this97._currentDistanceMeasurement.xAxisVisible=false;_this97._currentDistanceMeasurement.yAxisVisible=false;_this97._currentDistanceMeasurement.zAxisVisible=false;_this97._currentDistanceMeasurement.wireVisible=false;_this97._currentDistanceMeasurement.originVisible=true;_this97._currentDistanceMeasurement.targetVisible=false;_this97._currentDistanceMeasurement.clickable=false;_this97._touchState=WAITING_FOR_TARGET_TOUCH_START;_this97.distanceMeasurementsPlugin.fire("measurementStart",_this97._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
20434
20453
|
}else{if(_this97._currentDistanceMeasurement){_this97._currentDistanceMeasurement.destroy();}_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
20435
20454
|
}}enableCameraNavigation();break;case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this97.pointerLens){_this97.pointerLens.visible=false;}if(!_this97._currentDistanceMeasurement){if(_this97.pointerLens){_this97.pointerLens.snapped=false;_this97.pointerLens.visible=false;}_this97._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (no measurement) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
20436
20455
|
}else{_this97._touchState=WAITING_FOR_TARGET_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (picked, begin measurement) -> WAITING_FOR_TARGET_TOUCH_START")
|
|
@@ -21533,7 +21552,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
|
|
|
21533
21552
|
* @param {Number} frameIdx Index of the frame to scrub to.
|
|
21534
21553
|
*/},{key:"scrubToFrame",value:function scrubToFrame(frameIdx){var cameraPath=this._cameraPath;if(!cameraPath){return;}var camera=this.scene.camera;if(!camera){return;}var frame=cameraPath.frames[frameIdx];if(!frame){this.error("playToFrame - frame index out of range: "+frameIdx);return;}cameraPath.loadFrame(this._t);this.state=CameraPathAnimation.SCRUBBING;}/**
|
|
21535
21554
|
* Stops playing this CameraPathAnimation.
|
|
21536
|
-
*/},{key:"stop",value:function stop(){this.state=CameraPathAnimation.SCRUBBING;this.fire("stopped");}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CameraPathAnimation.prototype),"destroy",this).call(this);this.scene.off(this._tick);}}]);return CameraPathAnimation;}(Component);CameraPathAnimation.STOPPED=0;CameraPathAnimation.SCRUBBING=1;CameraPathAnimation.PLAYING=2;CameraPathAnimation.PLAYING_TO=3;var tempVec3$3=math.vec3();var tempVec3b$5=math.vec3();math.vec3();var zeroVec$
|
|
21555
|
+
*/},{key:"stop",value:function stop(){this.state=CameraPathAnimation.SCRUBBING;this.fire("stopped");}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CameraPathAnimation.prototype),"destroy",this).call(this);this.scene.off(this._tick);}}]);return CameraPathAnimation;}(Component);CameraPathAnimation.STOPPED=0;CameraPathAnimation.SCRUBBING=1;CameraPathAnimation.PLAYING=2;CameraPathAnimation.PLAYING_TO=3;var tempVec3$3=math.vec3();var tempVec3b$5=math.vec3();math.vec3();var zeroVec$1=math.vec3([0,-1,0]);var tempQuat=math.vec4([0,0,0,1]);/**
|
|
21537
21556
|
* @desc A plane-shaped 3D object containing a bitmap image.
|
|
21538
21557
|
*
|
|
21539
21558
|
* Use ````ImagePlane```` to embed bitmap images in your scenes.
|
|
@@ -21769,7 +21788,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
|
|
|
21769
21788
|
* Default is ````true````.
|
|
21770
21789
|
*
|
|
21771
21790
|
* @type {Boolean}
|
|
21772
|
-
*/,set:function set(dir){this._dir.set(dir||[0,0,-1]);if(dir){var origin=this.scene.center;var negDir=[-this._dir[0],-this._dir[1],-this._dir[2]];math.subVec3(origin,this.position,tempVec3$3);var dist=-math.dotVec3(negDir,tempVec3$3);math.normalizeVec3(negDir);math.mulVec3Scalar(negDir,dist,tempVec3b$5);math.vec3PairToQuaternion(zeroVec$
|
|
21791
|
+
*/,set:function set(dir){this._dir.set(dir||[0,0,-1]);if(dir){var origin=this.scene.center;var negDir=[-this._dir[0],-this._dir[1],-this._dir[2]];math.subVec3(origin,this.position,tempVec3$3);var dist=-math.dotVec3(negDir,tempVec3$3);math.normalizeVec3(negDir);math.mulVec3Scalar(negDir,dist,tempVec3b$5);math.vec3PairToQuaternion(zeroVec$1,dir,tempQuat);this._node.quaternion=tempQuat;}}},{key:"collidable",get:/**
|
|
21773
21792
|
* Gets if this ````ImagePlane```` is included in boundary calculations.
|
|
21774
21793
|
*
|
|
21775
21794
|
* Default is ````true````.
|
|
@@ -21920,7 +21939,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
|
|
|
21920
21939
|
* @param {Number} [cfg.quadraticAttenuation=0]Quadratic attenuation factor.
|
|
21921
21940
|
* @param {String} [cfg.space="view"]The coordinate system this PointLight is defined in - "view" or "world".
|
|
21922
21941
|
* @param {Boolean} [cfg.castsShadow=false] Flag which indicates if this PointLight casts a castsShadow.
|
|
21923
|
-
*/function PointLight(owner){var _this107;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointLight);_this107=_super136.call(this,owner,cfg);var self=_assertThisInitialized(_this107);_this107._shadowRenderBuf=null;_this107._shadowViewMatrix=null;_this107._shadowProjMatrix=null;_this107._shadowViewMatrixDirty=true;_this107._shadowProjMatrixDirty=true;var camera=_this107.scene.camera;var canvas=_this107.scene.canvas;_this107._onCameraViewMatrix=camera.on("viewMatrix",function(){_this107._shadowViewMatrixDirty=true;});_this107._onCameraProjMatrix=camera.on("projMatrix",function(){_this107._shadowProjMatrixDirty=true;});_this107._onCanvasBoundary=canvas.on("boundary",function(){_this107._shadowProjMatrixDirty=true;});_this107._state=new RenderState({type:"point",pos:math.vec3([1.0,1.0,1.0]),color:math.vec3([0.7,0.7,0.8]),intensity:1.0,attenuation:[0.0,0.0,0.0],space:cfg.space||"view",castsShadow:false,getShadowViewMatrix:function getShadowViewMatrix(){if(self._shadowViewMatrixDirty){if(!self._shadowViewMatrix){self._shadowViewMatrix=math.identityMat4();}var eye=self._state.pos;var look=camera.look;var
|
|
21942
|
+
*/function PointLight(owner){var _this107;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,PointLight);_this107=_super136.call(this,owner,cfg);var self=_assertThisInitialized(_this107);_this107._shadowRenderBuf=null;_this107._shadowViewMatrix=null;_this107._shadowProjMatrix=null;_this107._shadowViewMatrixDirty=true;_this107._shadowProjMatrixDirty=true;var camera=_this107.scene.camera;var canvas=_this107.scene.canvas;_this107._onCameraViewMatrix=camera.on("viewMatrix",function(){_this107._shadowViewMatrixDirty=true;});_this107._onCameraProjMatrix=camera.on("projMatrix",function(){_this107._shadowProjMatrixDirty=true;});_this107._onCanvasBoundary=canvas.on("boundary",function(){_this107._shadowProjMatrixDirty=true;});_this107._state=new RenderState({type:"point",pos:math.vec3([1.0,1.0,1.0]),color:math.vec3([0.7,0.7,0.8]),intensity:1.0,attenuation:[0.0,0.0,0.0],space:cfg.space||"view",castsShadow:false,getShadowViewMatrix:function getShadowViewMatrix(){if(self._shadowViewMatrixDirty){if(!self._shadowViewMatrix){self._shadowViewMatrix=math.identityMat4();}var eye=self._state.pos;var look=camera.look;var _up4=camera.up;math.lookAtMat4v(eye,look,_up4,self._shadowViewMatrix);self._shadowViewMatrixDirty=false;}return self._shadowViewMatrix;},getShadowProjMatrix:function getShadowProjMatrix(){if(self._shadowProjMatrixDirty){// TODO: Set when canvas resizes
|
|
21924
21943
|
if(!self._shadowProjMatrix){self._shadowProjMatrix=math.identityMat4();}var _canvas4=self.scene.canvas.canvas;math.perspectiveMat4(70*(Math.PI/180.0),_canvas4.clientWidth/_canvas4.clientHeight,0.1,500.0,self._shadowProjMatrix);self._shadowProjMatrixDirty=false;}return self._shadowProjMatrix;},getShadowRenderBuf:function getShadowRenderBuf(){if(!self._shadowRenderBuf){self._shadowRenderBuf=new RenderBuffer(self.scene.canvas.canvas,self.scene.canvas.gl,{size:[1024,1024]});// Super old mobile devices have a limit of 1024x1024 textures
|
|
21925
21944
|
}return self._shadowRenderBuf;}});_this107.pos=cfg.pos;_this107.color=cfg.color;_this107.intensity=cfg.intensity;_this107.constantAttenuation=cfg.constantAttenuation;_this107.linearAttenuation=cfg.linearAttenuation;_this107.quadraticAttenuation=cfg.quadraticAttenuation;_this107.castsShadow=cfg.castsShadow;_this107.scene._lightCreated(_assertThisInitialized(_this107));return _this107;}/**
|
|
21926
21945
|
* Sets the position of this PointLight.
|
|
@@ -25193,7 +25212,7 @@ snapshotCanvas.getContext("2d").resetTransform();case 26:_i508++;_context2.next=
|
|
|
25193
25212
|
*
|
|
25194
25213
|
*/},{key:"endSnapshot",value:function endSnapshot(){if(!this._snapshotBegun){return;}this.scene._renderer.endSnapshot();this.scene._renderer.render({force:true});this._snapshotBegun=false;}/** Destroys this Viewer.
|
|
25195
25214
|
*/},{key:"destroy",value:function destroy(){var plugins=this._plugins.slice();// Array will modify as we delete plugins
|
|
25196
|
-
for(var _i509=0,len=plugins.length;_i509<len;_i509++){var plugin=plugins[_i509];plugin.destroy();}this.scene.destroy();}}]);return Viewer;}();function assert$5(condition,message){if(!condition){throw new Error(message||'loader assertion failed.');}}var isBrowser$4=Boolean((typeof process==="undefined"?"undefined":_typeof(process))!=='object'||String(process)!=='[object process]'||process.browser);var matches$1=typeof process!=='undefined'&&process.version&&/v([0-9]*)/.exec(process.version);matches$1&&parseFloat(matches$1[1])||0;var VERSION$9="3.2.6";function assert$4(condition,message){if(!condition){throw new Error(message||'loaders.gl assertion failed.');}}var globals$2={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document};var global_=globals$2.global||globals$2.self||globals$2.window||{};var isBrowser$3=(typeof process==="undefined"?"undefined":_typeof(process))!=='object'||String(process)!=='[object process]'||process.browser;var isWorker=typeof importScripts==='function';var isMobile=typeof window!=='undefined'&&typeof window.orientation!=='undefined';var matches=typeof process!=='undefined'&&process.version&&/v([0-9]*)/.exec(process.version);matches&&parseFloat(matches[1])||0;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;}var WorkerJob=/*#__PURE__*/function(){function WorkerJob(jobName,workerThread){var _this120=this;_classCallCheck(this,WorkerJob);_defineProperty(this,"name",void 0);_defineProperty(this,"workerThread",void 0);_defineProperty(this,"isRunning",true);_defineProperty(this,"result",void 0);_defineProperty(this,"_resolve",function(){});_defineProperty(this,"_reject",function(){});this.name=jobName;this.workerThread=workerThread;this.result=new Promise(function(resolve,reject){_this120._resolve=resolve;_this120._reject=reject;});}_createClass(WorkerJob,[{key:"postMessage",value:function postMessage(type,payload){this.workerThread.postMessage({source:'loaders.gl',type:type,payload:payload});}},{key:"done",value:function done(value){assert$4(this.isRunning);this.isRunning=false;this._resolve(value);}},{key:"error",value:function error(_error){assert$4(this.isRunning);this.isRunning=false;this._reject(_error);}}]);return WorkerJob;}();var Worker$1=/*#__PURE__*/_createClass(function Worker$1(){_classCallCheck(this,Worker$1);});var workerURLCache=new Map();function getLoadableWorkerURL(props){assert$4(props.source&&!props.url||!props.source&&props.url);var workerURL=workerURLCache.get(props.source||props.url);if(!workerURL){if(props.url){workerURL=getLoadableWorkerURLFromURL(props.url);workerURLCache.set(props.url,workerURL);}if(props.source){workerURL=getLoadableWorkerURLFromSource(props.source);workerURLCache.set(props.source,workerURL);}}assert$4(workerURL);return workerURL;}function getLoadableWorkerURLFromURL(url){if(!url.startsWith('http')){return url;}var workerSource=buildScriptSource(url);return getLoadableWorkerURLFromSource(workerSource);}function getLoadableWorkerURLFromSource(workerSource){var blob=new Blob([workerSource],{type:'application/javascript'});return URL.createObjectURL(blob);}function buildScriptSource(workerUrl){return"try {\n importScripts('".concat(workerUrl,"');\n} catch (error) {\n console.error(error);\n throw error;\n}");}function getTransferList(object){var recursive=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var transfers=arguments.length>2?arguments[2]:undefined;var transfersSet=transfers||new Set();if(!object);else if(isTransferable(object)){transfersSet.add(object);}else if(isTransferable(object.buffer)){transfersSet.add(object.buffer);}else if(ArrayBuffer.isView(object));else if(recursive&&_typeof(object)==='object'){for(var key in object){getTransferList(object[key],recursive,transfersSet);}}return transfers===undefined?Array.from(transfersSet):[];}function isTransferable(object){if(!object){return false;}if(object instanceof ArrayBuffer){return true;}if(typeof MessagePort!=='undefined'&&object instanceof MessagePort){return true;}if(typeof ImageBitmap!=='undefined'&&object instanceof ImageBitmap){return true;}if(typeof OffscreenCanvas!=='undefined'&&object instanceof OffscreenCanvas){return true;}return false;}var NOOP=function NOOP(){};var WorkerThread=/*#__PURE__*/function(){function WorkerThread(props){_classCallCheck(this,WorkerThread);_defineProperty(this,"name",void 0);_defineProperty(this,"source",void 0);_defineProperty(this,"url",void 0);_defineProperty(this,"terminated",false);_defineProperty(this,"worker",void 0);_defineProperty(this,"onMessage",void 0);_defineProperty(this,"onError",void 0);_defineProperty(this,"_loadableURL",'');var name=props.name,source=props.source,url=props.url;assert$4(source||url);this.name=name;this.source=source;this.url=url;this.onMessage=NOOP;this.onError=function(error){return console.log(error);};this.worker=isBrowser$3?this._createBrowserWorker():this._createNodeWorker();}_createClass(WorkerThread,[{key:"destroy",value:function destroy(){this.onMessage=NOOP;this.onError=NOOP;this.worker.terminate();this.terminated=true;}},{key:"isRunning",get:function get(){return Boolean(this.onMessage);}},{key:"postMessage",value:function postMessage(data,transferList){transferList=transferList||getTransferList(data);this.worker.postMessage(data,transferList);}},{key:"_getErrorFromErrorEvent",value:function _getErrorFromErrorEvent(event){var message='Failed to load ';message+="worker ".concat(this.name," from ").concat(this.url,". ");if(event.message){message+="".concat(event.message," in ");}if(event.lineno){message+=":".concat(event.lineno,":").concat(event.colno);}return new Error(message);}},{key:"_createBrowserWorker",value:function _createBrowserWorker(){var _this121=this;this._loadableURL=getLoadableWorkerURL({source:this.source,url:this.url});var worker=new Worker(this._loadableURL,{name:this.name});worker.onmessage=function(event){if(!event.data){_this121.onError(new Error('No data received'));}else{_this121.onMessage(event.data);}};worker.onerror=function(error){_this121.onError(_this121._getErrorFromErrorEvent(error));_this121.terminated=true;};worker.onmessageerror=function(event){return console.error(event);};return worker;}},{key:"_createNodeWorker",value:function _createNodeWorker(){var _this122=this;var worker;if(this.url){var absolute=this.url.includes(':/')||this.url.startsWith('/');var url=absolute?this.url:"./".concat(this.url);worker=new Worker$1(url,{eval:false});}else if(this.source){worker=new Worker$1(this.source,{eval:true});}else{throw new Error('no worker');}worker.on('message',function(data){_this122.onMessage(data);});worker.on('error',function(error){_this122.onError(error);});worker.on('exit',function(code){});return worker;}}],[{key:"isSupported",value:function isSupported(){return typeof Worker!=='undefined'&&isBrowser$3||_typeof(Worker$1)!==undefined;}}]);return WorkerThread;}();var WorkerPool=/*#__PURE__*/function(){function WorkerPool(props){_classCallCheck(this,WorkerPool);_defineProperty(this,"name",'unnamed');_defineProperty(this,"source",void 0);_defineProperty(this,"url",void 0);_defineProperty(this,"maxConcurrency",1);_defineProperty(this,"maxMobileConcurrency",1);_defineProperty(this,"onDebug",function(){});_defineProperty(this,"reuseWorkers",true);_defineProperty(this,"props",{});_defineProperty(this,"jobQueue",[]);_defineProperty(this,"idleQueue",[]);_defineProperty(this,"count",0);_defineProperty(this,"isDestroyed",false);this.source=props.source;this.url=props.url;this.setProps(props);}_createClass(WorkerPool,[{key:"destroy",value:function destroy(){this.idleQueue.forEach(function(worker){return worker.destroy();});this.isDestroyed=true;}},{key:"setProps",value:function setProps(props){this.props=_objectSpread(_objectSpread({},this.props),props);if(props.name!==undefined){this.name=props.name;}if(props.maxConcurrency!==undefined){this.maxConcurrency=props.maxConcurrency;}if(props.maxMobileConcurrency!==undefined){this.maxMobileConcurrency=props.maxMobileConcurrency;}if(props.reuseWorkers!==undefined){this.reuseWorkers=props.reuseWorkers;}if(props.onDebug!==undefined){this.onDebug=props.onDebug;}}},{key:"startJob",value:function(){var _startJob=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name){var _this123=this;var onMessage,onError,startPromise,_args2=arguments;return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:onMessage=_args2.length>1&&_args2[1]!==undefined?_args2[1]:function(job,type,data){return job.done(data);};onError=_args2.length>2&&_args2[2]!==undefined?_args2[2]:function(job,error){return job.error(error);};startPromise=new Promise(function(onStart){_this123.jobQueue.push({name:name,onMessage:onMessage,onError:onError,onStart:onStart});return _this123;});this._startQueuedJob();_context3.next=6;return startPromise;case 6:return _context3.abrupt("return",_context3.sent);case 7:case"end":return _context3.stop();}}},_callee2,this);}));function startJob(_x7){return _startJob.apply(this,arguments);}return startJob;}()},{key:"_startQueuedJob",value:function(){var _startQueuedJob2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var workerThread,queuedJob,job;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:if(this.jobQueue.length){_context4.next=2;break;}return _context4.abrupt("return");case 2:workerThread=this._getAvailableWorker();if(workerThread){_context4.next=5;break;}return _context4.abrupt("return");case 5:queuedJob=this.jobQueue.shift();if(!queuedJob){_context4.next=18;break;}this.onDebug({message:'Starting job',name:queuedJob.name,workerThread:workerThread,backlog:this.jobQueue.length});job=new WorkerJob(queuedJob.name,workerThread);workerThread.onMessage=function(data){return queuedJob.onMessage(job,data.type,data.payload);};workerThread.onError=function(error){return queuedJob.onError(job,error);};queuedJob.onStart(job);_context4.prev=12;_context4.next=15;return job.result;case 15:_context4.prev=15;this.returnWorkerToQueue(workerThread);return _context4.finish(15);case 18:case"end":return _context4.stop();}}},_callee3,this,[[12,,15,18]]);}));function _startQueuedJob(){return _startQueuedJob2.apply(this,arguments);}return _startQueuedJob;}()},{key:"returnWorkerToQueue",value:function returnWorkerToQueue(worker){var shouldDestroyWorker=this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency();if(shouldDestroyWorker){worker.destroy();this.count--;}else{this.idleQueue.push(worker);}if(!this.isDestroyed){this._startQueuedJob();}}},{key:"_getAvailableWorker",value:function _getAvailableWorker(){if(this.idleQueue.length>0){return this.idleQueue.shift()||null;}if(this.count<this._getMaxConcurrency()){this.count++;var _name5="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new WorkerThread({name:_name5,source:this.source,url:this.url});}return null;}},{key:"_getMaxConcurrency",value:function _getMaxConcurrency(){return isMobile?this.maxMobileConcurrency:this.maxConcurrency;}}],[{key:"isSupported",value:function isSupported(){return WorkerThread.isSupported();}}]);return WorkerPool;}();var DEFAULT_PROPS={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:true,onDebug:function onDebug(){}};var WorkerFarm=/*#__PURE__*/function(){function WorkerFarm(props){_classCallCheck(this,WorkerFarm);_defineProperty(this,"props",void 0);_defineProperty(this,"workerPools",new Map());this.props=_objectSpread({},DEFAULT_PROPS);this.setProps(props);this.workerPools=new Map();}_createClass(WorkerFarm,[{key:"destroy",value:function destroy(){var _iterator5=_createForOfIteratorHelper(this.workerPools.values()),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var workerPool=_step5.value;workerPool.destroy();}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}this.workerPools=new Map();}},{key:"setProps",value:function setProps(props){this.props=_objectSpread(_objectSpread({},this.props),props);var _iterator6=_createForOfIteratorHelper(this.workerPools.values()),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var workerPool=_step6.value;workerPool.setProps(this._getWorkerPoolProps());}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}}},{key:"getWorkerPool",value:function getWorkerPool(options){var name=options.name,source=options.source,url=options.url;var workerPool=this.workerPools.get(name);if(!workerPool){workerPool=new WorkerPool({name:name,source:source,url:url});workerPool.setProps(this._getWorkerPoolProps());this.workerPools.set(name,workerPool);}return workerPool;}},{key:"_getWorkerPoolProps",value:function _getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug};}}],[{key:"isSupported",value:function isSupported(){return WorkerThread.isSupported();}},{key:"getWorkerFarm",value:function getWorkerFarm(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};WorkerFarm._workerFarm=WorkerFarm._workerFarm||new WorkerFarm({});WorkerFarm._workerFarm.setProps(props);return WorkerFarm._workerFarm;}}]);return WorkerFarm;}();_defineProperty(WorkerFarm,"_workerFarm",void 0);var NPM_TAG='latest';function getWorkerURL(worker){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var workerOptions=options[worker.id]||{};var workerFile="".concat(worker.id,"-worker.js");var url=workerOptions.workerUrl;if(!url&&worker.id==='compression'){url=options.workerUrl;}if(options._workerType==='test'){url="modules/".concat(worker.module,"/dist/").concat(workerFile);}if(!url){var version=worker.version;if(version==='latest'){version=NPM_TAG;}var versionTag=version?"@".concat(version):'';url="https://unpkg.com/@loaders.gl/".concat(worker.module).concat(versionTag,"/dist/").concat(workerFile);}assert$4(url);return url;}function validateWorkerVersion(worker){var coreVersion=arguments.length>1&&arguments[1]!==undefined?arguments[1]:VERSION$9;assert$4(worker,'no worker provided');var workerVersion=worker.version;if(!coreVersion||!workerVersion){return false;}return true;}var ChildProcessProxy={};var node=/*#__PURE__*/Object.freeze({__proto__:null,'default':ChildProcessProxy});var VERSION$8="3.2.6";var loadLibraryPromises={};function loadLibrary(_x8){return _loadLibrary.apply(this,arguments);}function _loadLibrary(){_loadLibrary=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(libraryUrl){var moduleName,options,_args6=arguments;return _regeneratorRuntime().wrap(function _callee8$(_context12){while(1){switch(_context12.prev=_context12.next){case 0:moduleName=_args6.length>1&&_args6[1]!==undefined?_args6[1]:null;options=_args6.length>2&&_args6[2]!==undefined?_args6[2]:{};if(moduleName){libraryUrl=getLibraryUrl(libraryUrl,moduleName,options);}loadLibraryPromises[libraryUrl]=loadLibraryPromises[libraryUrl]||loadLibraryFromFile(libraryUrl);_context12.next=6;return loadLibraryPromises[libraryUrl];case 6:return _context12.abrupt("return",_context12.sent);case 7:case"end":return _context12.stop();}}},_callee8);}));return _loadLibrary.apply(this,arguments);}function getLibraryUrl(library,moduleName,options){if(library.startsWith('http')){return library;}var modules=options.modules||{};if(modules[library]){return modules[library];}if(!isBrowser$3){return"modules/".concat(moduleName,"/dist/libs/").concat(library);}if(options.CDN){assert$4(options.CDN.startsWith('http'));return"".concat(options.CDN,"/").concat(moduleName,"@").concat(VERSION$8,"/dist/libs/").concat(library);}if(isWorker){return"../src/libs/".concat(library);}return"modules/".concat(moduleName,"/src/libs/").concat(library);}function loadLibraryFromFile(_x9){return _loadLibraryFromFile.apply(this,arguments);}function _loadLibraryFromFile(){_loadLibraryFromFile=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(libraryUrl){var _response,response,scriptSource;return _regeneratorRuntime().wrap(function _callee9$(_context13){while(1){switch(_context13.prev=_context13.next){case 0:if(!libraryUrl.endsWith('wasm')){_context13.next=7;break;}_context13.next=3;return fetch(libraryUrl);case 3:_response=_context13.sent;_context13.next=6;return _response.arrayBuffer();case 6:return _context13.abrupt("return",_context13.sent);case 7:if(isBrowser$3){_context13.next=20;break;}_context13.prev=8;_context13.t0=node&&undefined;if(!_context13.t0){_context13.next=14;break;}_context13.next=13;return undefined(libraryUrl);case 13:_context13.t0=_context13.sent;case 14:return _context13.abrupt("return",_context13.t0);case 17:_context13.prev=17;_context13.t1=_context13["catch"](8);return _context13.abrupt("return",null);case 20:if(!isWorker){_context13.next=22;break;}return _context13.abrupt("return",importScripts(libraryUrl));case 22:_context13.next=24;return fetch(libraryUrl);case 24:response=_context13.sent;_context13.next=27;return response.text();case 27:scriptSource=_context13.sent;return _context13.abrupt("return",loadLibraryFromString(scriptSource,libraryUrl));case 29:case"end":return _context13.stop();}}},_callee9,null,[[8,17]]);}));return _loadLibraryFromFile.apply(this,arguments);}function loadLibraryFromString(scriptSource,id){if(!isBrowser$3){return undefined&&undefined(scriptSource,id);}if(isWorker){eval.call(global_,scriptSource);return null;}var script=document.createElement('script');script.id=id;try{script.appendChild(document.createTextNode(scriptSource));}catch(e){script.text=scriptSource;}document.body.appendChild(script);return null;}function canParseWithWorker(loader,options){if(!WorkerFarm.isSupported()){return false;}if(!isBrowser$3&&!(options!==null&&options!==void 0&&options._nodeWorkers)){return false;}return loader.worker&&(options===null||options===void 0?void 0:options.worker);}function parseWithWorker(_x10,_x11,_x12,_x13,_x14){return _parseWithWorker.apply(this,arguments);}function _parseWithWorker(){_parseWithWorker=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(loader,data,options,context,parseOnMainThread){var name,url,workerFarm,workerPool,job,result;return _regeneratorRuntime().wrap(function _callee10$(_context14){while(1){switch(_context14.prev=_context14.next){case 0:name=loader.id;url=getWorkerURL(loader,options);workerFarm=WorkerFarm.getWorkerFarm(options);workerPool=workerFarm.getWorkerPool({name:name,url:url});options=JSON.parse(JSON.stringify(options));context=JSON.parse(JSON.stringify(context||{}));_context14.next=8;return workerPool.startJob('process-on-worker',onMessage.bind(null,parseOnMainThread));case 8:job=_context14.sent;job.postMessage('process',{input:data,options:options,context:context});_context14.next=12;return job.result;case 12:result=_context14.sent;_context14.next=15;return result.result;case 15:return _context14.abrupt("return",_context14.sent);case 16:case"end":return _context14.stop();}}},_callee10);}));return _parseWithWorker.apply(this,arguments);}function onMessage(_x15,_x16,_x17,_x18){return _onMessage2.apply(this,arguments);}function _onMessage2(){_onMessage2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(parseOnMainThread,job,type,payload){var id,input,options,result,message;return _regeneratorRuntime().wrap(function _callee11$(_context15){while(1){switch(_context15.prev=_context15.next){case 0:_context15.t0=type;_context15.next=_context15.t0==='done'?3:_context15.t0==='error'?5:_context15.t0==='process'?7:20;break;case 3:job.done(payload);return _context15.abrupt("break",21);case 5:job.error(new Error(payload.error));return _context15.abrupt("break",21);case 7:id=payload.id,input=payload.input,options=payload.options;_context15.prev=8;_context15.next=11;return parseOnMainThread(input,options);case 11:result=_context15.sent;job.postMessage('done',{id:id,result:result});_context15.next=19;break;case 15:_context15.prev=15;_context15.t1=_context15["catch"](8);message=_context15.t1 instanceof Error?_context15.t1.message:'unknown error';job.postMessage('error',{id:id,error:message});case 19:return _context15.abrupt("break",21);case 20:console.warn("parse-with-worker unknown message ".concat(type));case 21:case"end":return _context15.stop();}}},_callee11,null,[[8,15]]);}));return _onMessage2.apply(this,arguments);}function getFirstCharacters$1(data){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5;if(typeof data==='string'){return data.slice(0,length);}else if(ArrayBuffer.isView(data)){return getMagicString$2(data.buffer,data.byteOffset,length);}else if(data instanceof ArrayBuffer){var byteOffset=0;return getMagicString$2(data,byteOffset,length);}return'';}function getMagicString$2(arrayBuffer,byteOffset,length){if(arrayBuffer.byteLength<=byteOffset+length){return'';}var dataView=new DataView(arrayBuffer);var magic='';for(var _i510=0;_i510<length;_i510++){magic+=String.fromCharCode(dataView.getUint8(byteOffset+_i510));}return magic;}function parseJSON(string){try{return JSON.parse(string);}catch(_){throw new Error("Failed to parse JSON from data starting with \"".concat(getFirstCharacters$1(string),"\""));}}function isBuffer$1(value){return value&&_typeof(value)==='object'&&value.isBuffer;}function bufferToArrayBuffer(buffer){if(isBuffer$1(buffer)){var typedArray=new Uint8Array(buffer.buffer,buffer.byteOffset,buffer.length);return typedArray.slice().buffer;}return buffer;}function toArrayBuffer(data){if(isBuffer$1(data)){return bufferToArrayBuffer(data);}if(data instanceof ArrayBuffer){return data;}if(ArrayBuffer.isView(data)){if(data.byteOffset===0&&data.byteLength===data.buffer.byteLength){return data.buffer;}return data.buffer.slice(data.byteOffset,data.byteOffset+data.byteLength);}if(typeof data==='string'){var text=data;var uint8Array=new TextEncoder().encode(text);return uint8Array.buffer;}if(data&&_typeof(data)==='object'&&data._toArrayBuffer){return data._toArrayBuffer();}throw new Error('toArrayBuffer');}function compareArrayBuffers(arrayBuffer1,arrayBuffer2,byteLength){byteLength=byteLength||arrayBuffer1.byteLength;if(arrayBuffer1.byteLength<byteLength||arrayBuffer2.byteLength<byteLength){return false;}var array1=new Uint8Array(arrayBuffer1);var array2=new Uint8Array(arrayBuffer2);for(var _i511=0;_i511<array1.length;++_i511){if(array1[_i511]!==array2[_i511]){return false;}}return true;}function concatenateArrayBuffers(){for(var _len101=arguments.length,sources=new Array(_len101),_key6=0;_key6<_len101;_key6++){sources[_key6]=arguments[_key6];}var sourceArrays=sources.map(function(source2){return source2 instanceof ArrayBuffer?new Uint8Array(source2):source2;});var byteLength=sourceArrays.reduce(function(length,typedArray){return length+typedArray.byteLength;},0);var result=new Uint8Array(byteLength);var offset=0;var _iterator7=_createForOfIteratorHelper(sourceArrays),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var sourceArray=_step7.value;result.set(sourceArray,offset);offset+=sourceArray.byteLength;}}catch(err){_iterator7.e(err);}finally{_iterator7.f();}return result.buffer;}function sliceArrayBuffer(arrayBuffer,byteOffset,byteLength){var subArray=byteLength!==undefined?new Uint8Array(arrayBuffer).subarray(byteOffset,byteOffset+byteLength):new Uint8Array(arrayBuffer).subarray(byteOffset);var arrayCopy=new Uint8Array(subArray);return arrayCopy.buffer;}function padToNBytes(byteLength,padding){assert$5(byteLength>=0);assert$5(padding>0);return byteLength+(padding-1)&~(padding-1);}function copyToArray(source,target,targetOffset){var sourceArray;if(source instanceof ArrayBuffer){sourceArray=new Uint8Array(source);}else{var srcByteOffset=source.byteOffset;var srcByteLength=source.byteLength;sourceArray=new Uint8Array(source.buffer||source.arrayBuffer,srcByteOffset,srcByteLength);}target.set(sourceArray,targetOffset);return targetOffset+padToNBytes(sourceArray.byteLength,4);}function concatenateArrayBuffersAsync(_x19){return _concatenateArrayBuffersAsync.apply(this,arguments);}function _concatenateArrayBuffersAsync(){_concatenateArrayBuffersAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(asyncIterator){var arrayBuffers,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,chunk;return _regeneratorRuntime().wrap(function _callee12$(_context16){while(1){switch(_context16.prev=_context16.next){case 0:arrayBuffers=[];_iteratorAbruptCompletion=false;_didIteratorError=false;_context16.prev=3;_iterator=_asyncIterator(asyncIterator);case 5:_context16.next=7;return _iterator.next();case 7:if(!(_iteratorAbruptCompletion=!(_step=_context16.sent).done)){_context16.next=13;break;}chunk=_step.value;arrayBuffers.push(chunk);case 10:_iteratorAbruptCompletion=false;_context16.next=5;break;case 13:_context16.next=19;break;case 15:_context16.prev=15;_context16.t0=_context16["catch"](3);_didIteratorError=true;_iteratorError=_context16.t0;case 19:_context16.prev=19;_context16.prev=20;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context16.next=24;break;}_context16.next=24;return _iterator["return"]();case 24:_context16.prev=24;if(!_didIteratorError){_context16.next=27;break;}throw _iteratorError;case 27:return _context16.finish(24);case 28:return _context16.finish(19);case 29:return _context16.abrupt("return",concatenateArrayBuffers.apply(void 0,arrayBuffers));case 30:case"end":return _context16.stop();}}},_callee12,null,[[3,15,19,29],[20,,24,28]]);}));return _concatenateArrayBuffersAsync.apply(this,arguments);}var pathPrefix='';var fileAliases={};function resolvePath(filename){for(var alias in fileAliases){if(filename.startsWith(alias)){var replacement=fileAliases[alias];filename=filename.replace(alias,replacement);}}if(!filename.startsWith('http://')&&!filename.startsWith('https://')){filename="".concat(pathPrefix).concat(filename);}return filename;}function filename(url){var slashIndex=url&&url.lastIndexOf('/');return slashIndex>=0?url.substr(slashIndex+1):'';}var isBoolean=function isBoolean(x){return typeof x==='boolean';};var isFunction=function isFunction(x){return typeof x==='function';};var isObject=function isObject(x){return x!==null&&_typeof(x)==='object';};var isPureObject=function isPureObject(x){return isObject(x)&&x.constructor==={}.constructor;};var isIterable=function isIterable(x){return x&&typeof x[Symbol.iterator]==='function';};var isAsyncIterable=function isAsyncIterable(x){return x&&typeof x[Symbol.asyncIterator]==='function';};var isResponse=function isResponse(x){return typeof Response!=='undefined'&&x instanceof Response||x&&x.arrayBuffer&&x.text&&x.json;};var isBlob=function isBlob(x){return typeof Blob!=='undefined'&&x instanceof Blob;};var isBuffer=function isBuffer(x){return x&&_typeof(x)==='object'&&x.isBuffer;};var isReadableDOMStream=function isReadableDOMStream(x){return typeof ReadableStream!=='undefined'&&x instanceof ReadableStream||isObject(x)&&isFunction(x.tee)&&isFunction(x.cancel)&&isFunction(x.getReader);};var isReadableNodeStream=function isReadableNodeStream(x){return isObject(x)&&isFunction(x.read)&&isFunction(x.pipe)&&isBoolean(x.readable);};var isReadableStream=function isReadableStream(x){return isReadableDOMStream(x)||isReadableNodeStream(x);};var DATA_URL_PATTERN=/^data:([-\w.]+\/[-\w.+]+)(;|,)/;var MIME_TYPE_PATTERN=/^([-\w.]+\/[-\w.+]+)/;function parseMIMEType(mimeString){var matches=MIME_TYPE_PATTERN.exec(mimeString);if(matches){return matches[1];}return mimeString;}function parseMIMETypeFromURL(url){var matches=DATA_URL_PATTERN.exec(url);if(matches){return matches[1];}return'';}var QUERY_STRING_PATTERN=/\?.*/;function getResourceUrlAndType(resource){if(isResponse(resource)){var url=stripQueryString(resource.url||'');var contentTypeHeader=resource.headers.get('content-type')||'';return{url:url,type:parseMIMEType(contentTypeHeader)||parseMIMETypeFromURL(url)};}if(isBlob(resource)){return{url:stripQueryString(resource.name||''),type:resource.type||''};}if(typeof resource==='string'){return{url:stripQueryString(resource),type:parseMIMETypeFromURL(resource)};}return{url:'',type:''};}function getResourceContentLength(resource){if(isResponse(resource)){return resource.headers['content-length']||-1;}if(isBlob(resource)){return resource.size;}if(typeof resource==='string'){return resource.length;}if(resource instanceof ArrayBuffer){return resource.byteLength;}if(ArrayBuffer.isView(resource)){return resource.byteLength;}return-1;}function stripQueryString(url){return url.replace(QUERY_STRING_PATTERN,'');}function makeResponse(_x20){return _makeResponse.apply(this,arguments);}function _makeResponse(){_makeResponse=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(resource){var headers,contentLength,_getResourceUrlAndTyp3,url,type,initialDataUrl,response;return _regeneratorRuntime().wrap(function _callee13$(_context17){while(1){switch(_context17.prev=_context17.next){case 0:if(!isResponse(resource)){_context17.next=2;break;}return _context17.abrupt("return",resource);case 2:headers={};contentLength=getResourceContentLength(resource);if(contentLength>=0){headers['content-length']=String(contentLength);}_getResourceUrlAndTyp3=getResourceUrlAndType(resource),url=_getResourceUrlAndTyp3.url,type=_getResourceUrlAndTyp3.type;if(type){headers['content-type']=type;}_context17.next=9;return getInitialDataUrl(resource);case 9:initialDataUrl=_context17.sent;if(initialDataUrl){headers['x-first-bytes']=initialDataUrl;}if(typeof resource==='string'){resource=new TextEncoder().encode(resource);}response=new Response(resource,{headers:headers});Object.defineProperty(response,'url',{value:url});return _context17.abrupt("return",response);case 15:case"end":return _context17.stop();}}},_callee13);}));return _makeResponse.apply(this,arguments);}function checkResponse(_x21){return _checkResponse.apply(this,arguments);}function _checkResponse(){_checkResponse=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(response){var message;return _regeneratorRuntime().wrap(function _callee14$(_context18){while(1){switch(_context18.prev=_context18.next){case 0:if(response.ok){_context18.next=5;break;}_context18.next=3;return getResponseError(response);case 3:message=_context18.sent;throw new Error(message);case 5:case"end":return _context18.stop();}}},_callee14);}));return _checkResponse.apply(this,arguments);}function getResponseError(_x22){return _getResponseError.apply(this,arguments);}function _getResponseError(){_getResponseError=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(response){var message,contentType,text;return _regeneratorRuntime().wrap(function _callee15$(_context19){while(1){switch(_context19.prev=_context19.next){case 0:message="Failed to fetch resource ".concat(response.url," (").concat(response.status,"): ");_context19.prev=1;contentType=response.headers.get('Content-Type');text=response.statusText;if(!contentType.includes('application/json')){_context19.next=11;break;}_context19.t0=text;_context19.t1=" ";_context19.next=9;return response.text();case 9:_context19.t2=_context19.sent;text=_context19.t0+=_context19.t1.concat.call(_context19.t1,_context19.t2);case 11:message+=text;message=message.length>60?"".concat(message.slice(0,60),"..."):message;_context19.next=17;break;case 15:_context19.prev=15;_context19.t3=_context19["catch"](1);case 17:return _context19.abrupt("return",message);case 18:case"end":return _context19.stop();}}},_callee15,null,[[1,15]]);}));return _getResponseError.apply(this,arguments);}function getInitialDataUrl(_x23){return _getInitialDataUrl.apply(this,arguments);}function _getInitialDataUrl(){_getInitialDataUrl=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(resource){var INITIAL_DATA_LENGTH,blobSlice,slice,_base;return _regeneratorRuntime().wrap(function _callee16$(_context20){while(1){switch(_context20.prev=_context20.next){case 0:INITIAL_DATA_LENGTH=5;if(!(typeof resource==='string')){_context20.next=3;break;}return _context20.abrupt("return","data:,".concat(resource.slice(0,INITIAL_DATA_LENGTH)));case 3:if(!(resource instanceof Blob)){_context20.next=8;break;}blobSlice=resource.slice(0,5);_context20.next=7;return new Promise(function(resolve){var reader=new FileReader();reader.onload=function(event){var _event$target;return resolve(event===null||event===void 0?void 0:(_event$target=event.target)===null||_event$target===void 0?void 0:_event$target.result);};reader.readAsDataURL(blobSlice);});case 7:return _context20.abrupt("return",_context20.sent);case 8:if(!(resource instanceof ArrayBuffer)){_context20.next=12;break;}slice=resource.slice(0,INITIAL_DATA_LENGTH);_base=arrayBufferToBase64(slice);return _context20.abrupt("return","data:base64,".concat(_base));case 12:return _context20.abrupt("return",null);case 13:case"end":return _context20.stop();}}},_callee16);}));return _getInitialDataUrl.apply(this,arguments);}function arrayBufferToBase64(buffer){var binary='';var bytes=new Uint8Array(buffer);for(var _i512=0;_i512<bytes.byteLength;_i512++){binary+=String.fromCharCode(bytes[_i512]);}return btoa(binary);}function fetchFile(_x24,_x25){return _fetchFile.apply(this,arguments);}function _fetchFile(){_fetchFile=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(url,options){var fetchOptions;return _regeneratorRuntime().wrap(function _callee17$(_context21){while(1){switch(_context21.prev=_context21.next){case 0:if(!(typeof url==='string')){_context21.next=7;break;}url=resolvePath(url);fetchOptions=options;if(options!==null&&options!==void 0&&options.fetch&&typeof(options===null||options===void 0?void 0:options.fetch)!=='function'){fetchOptions=options.fetch;}_context21.next=6;return fetch(url,fetchOptions);case 6:return _context21.abrupt("return",_context21.sent);case 7:_context21.next=9;return makeResponse(url);case 9:return _context21.abrupt("return",_context21.sent);case 10:case"end":return _context21.stop();}}},_callee17);}));return _fetchFile.apply(this,arguments);}function isElectron$1(mockUserAgent){if(typeof window!=='undefined'&&_typeof(window.process)==='object'&&window.process.type==='renderer'){return true;}if(typeof process!=='undefined'&&_typeof(process.versions)==='object'&&Boolean(process.versions.electron)){return true;}var realUserAgent=(typeof navigator==="undefined"?"undefined":_typeof(navigator))==='object'&&typeof navigator.userAgent==='string'&&navigator.userAgent;var userAgent=mockUserAgent||realUserAgent;if(userAgent&&userAgent.indexOf('Electron')>=0){return true;}return false;}function isBrowser$2(){var isNode=(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&String(process)==='[object process]'&&!process.browser;return!isNode||isElectron$1();}var globals$1={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document,process:(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&process};var window_$1=globals$1.window||globals$1.self||globals$1.global;var process_$1=globals$1.process||{};var VERSION$7=typeof __VERSION__!=='undefined'?__VERSION__:'untranspiled source';var isBrowser$1=isBrowser$2();function getStorage$1(type){try{var storage=window[type];var x='__storage_test__';storage.setItem(x,x);storage.removeItem(x);return storage;}catch(e){return null;}}var LocalStorage$1=/*#__PURE__*/function(){function LocalStorage$1(id,defaultSettings){var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'sessionStorage';_classCallCheck(this,LocalStorage$1);this.storage=getStorage$1(type);this.id=id;this.config={};Object.assign(this.config,defaultSettings);this._loadConfiguration();}_createClass(LocalStorage$1,[{key:"getConfiguration",value:function getConfiguration(){return this.config;}},{key:"setConfiguration",value:function setConfiguration(configuration){this.config={};return this.updateConfiguration(configuration);}},{key:"updateConfiguration",value:function updateConfiguration(configuration){Object.assign(this.config,configuration);if(this.storage){var serialized=JSON.stringify(this.config);this.storage.setItem(this.id,serialized);}return this;}},{key:"_loadConfiguration",value:function _loadConfiguration(){var configuration={};if(this.storage){var serializedConfiguration=this.storage.getItem(this.id);configuration=serializedConfiguration?JSON.parse(serializedConfiguration):{};}Object.assign(this.config,configuration);return this;}}]);return LocalStorage$1;}();function formatTime$1(ms){var formatted;if(ms<10){formatted="".concat(ms.toFixed(2),"ms");}else if(ms<100){formatted="".concat(ms.toFixed(1),"ms");}else if(ms<1000){formatted="".concat(ms.toFixed(0),"ms");}else{formatted="".concat((ms/1000).toFixed(2),"s");}return formatted;}function leftPad$1(string){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:8;var padLength=Math.max(length-string.length,0);return"".concat(' '.repeat(padLength)).concat(string);}function formatImage$1(image,message,scale){var maxWidth=arguments.length>3&&arguments[3]!==undefined?arguments[3]:600;var imageUrl=image.src.replace(/\(/g,'%28').replace(/\)/g,'%29');if(image.width>maxWidth){scale=Math.min(scale,maxWidth/image.width);}var width=image.width*scale;var height=image.height*scale;var style=['font-size:1px;',"padding:".concat(Math.floor(height/2),"px ").concat(Math.floor(width/2),"px;"),"line-height:".concat(height,"px;"),"background:url(".concat(imageUrl,");"),"background-size:".concat(width,"px ").concat(height,"px;"),'color:transparent;'].join('');return["".concat(message," %c+"),style];}var COLOR$1={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function getColor$1(color){return typeof color==='string'?COLOR$1[color.toUpperCase()]||COLOR$1.WHITE:color;}function addColor$1(string,color,background){if(!isBrowser$1&&typeof string==='string'){if(color){color=getColor$1(color);string="\x1B[".concat(color,"m").concat(string,"\x1B[39m");}if(background){color=getColor$1(background);string="\x1B[".concat(background+10,"m").concat(string,"\x1B[49m");}}return string;}function autobind$1(obj){var predefined=arguments.length>1&&arguments[1]!==undefined?arguments[1]:['constructor'];var proto=Object.getPrototypeOf(obj);var propNames=Object.getOwnPropertyNames(proto);var _iterator8=_createForOfIteratorHelper(propNames),_step8;try{var _loop4=function _loop4(){var key=_step8.value;if(typeof obj[key]==='function'){if(!predefined.find(function(name){return key===name;})){obj[key]=obj[key].bind(obj);}}};for(_iterator8.s();!(_step8=_iterator8.n()).done;){_loop4();}}catch(err){_iterator8.e(err);}finally{_iterator8.f();}}function assert$3(condition,message){if(!condition){throw new Error(message||'Assertion failed');}}function getHiResTimestamp$1(){var timestamp;if(isBrowser$1&&window_$1.performance){timestamp=window_$1.performance.now();}else if(process_$1.hrtime){var timeParts=process_$1.hrtime();timestamp=timeParts[0]*1000+timeParts[1]/1e6;}else{timestamp=Date.now();}return timestamp;}var originalConsole$1={debug:isBrowser$1?console.debug||console.log:console.log,log:console.log,info:console.info,warn:console.warn,error:console.error};var DEFAULT_SETTINGS$1={enabled:true,level:0};function noop$1(){}var cache$1={};var ONCE$1={once:true};function getTableHeader$1(table){for(var key in table){for(var title in table[key]){return title||'untitled';}}return'empty';}var Log$1=/*#__PURE__*/function(){function Log$1(){var _ref16=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{id:''},id=_ref16.id;_classCallCheck(this,Log$1);this.id=id;this.VERSION=VERSION$7;this._startTs=getHiResTimestamp$1();this._deltaTs=getHiResTimestamp$1();this.LOG_THROTTLE_TIMEOUT=0;this._storage=new LocalStorage$1("__probe-".concat(this.id,"__"),DEFAULT_SETTINGS$1);this.userData={};this.timeStamp("".concat(this.id," started"));autobind$1(this);Object.seal(this);}_createClass(Log$1,[{key:"level",get:function get(){return this.getLevel();},set:function set(newLevel){this.setLevel(newLevel);}},{key:"isEnabled",value:function isEnabled(){return this._storage.config.enabled;}},{key:"getLevel",value:function getLevel(){return this._storage.config.level;}},{key:"getTotal",value:function getTotal(){return Number((getHiResTimestamp$1()-this._startTs).toPrecision(10));}},{key:"getDelta",value:function getDelta(){return Number((getHiResTimestamp$1()-this._deltaTs).toPrecision(10));}},{key:"priority",get:function get(){return this.level;},set:function set(newPriority){this.level=newPriority;}},{key:"getPriority",value:function getPriority(){return this.level;}},{key:"enable",value:function enable(){var enabled=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;this._storage.updateConfiguration({enabled:enabled});return this;}},{key:"setLevel",value:function setLevel(level){this._storage.updateConfiguration({level:level});return this;}},{key:"assert",value:function assert(condition,message){assert$3(condition,message);}},{key:"warn",value:function warn(message){return this._getLogFunction(0,message,originalConsole$1.warn,arguments,ONCE$1);}},{key:"error",value:function error(message){return this._getLogFunction(0,message,originalConsole$1.error,arguments);}},{key:"deprecated",value:function deprecated(oldUsage,newUsage){return this.warn("`".concat(oldUsage,"` is deprecated and will be removed in a later version. Use `").concat(newUsage,"` instead"));}},{key:"removed",value:function removed(oldUsage,newUsage){return this.error("`".concat(oldUsage,"` has been removed. Use `").concat(newUsage,"` instead"));}},{key:"probe",value:function probe(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.log,arguments,{time:true,once:true});}},{key:"log",value:function log(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.debug,arguments);}},{key:"info",value:function info(logLevel,message){return this._getLogFunction(logLevel,message,console.info,arguments);}},{key:"once",value:function once(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.debug||originalConsole$1.info,arguments,ONCE$1);}},{key:"table",value:function table(logLevel,_table,columns){if(_table){return this._getLogFunction(logLevel,_table,console.table||noop$1,columns&&[columns],{tag:getTableHeader$1(_table)});}return noop$1;}},{key:"image",value:function(_image6){function image(_x26){return _image6.apply(this,arguments);}image.toString=function(){return _image6.toString();};return image;}(function(_ref17){var logLevel=_ref17.logLevel,priority=_ref17.priority,image=_ref17.image,_ref17$message=_ref17.message,message=_ref17$message===void 0?'':_ref17$message,_ref17$scale=_ref17.scale,scale=_ref17$scale===void 0?1:_ref17$scale;if(!this._shouldLog(logLevel||priority)){return noop$1;}return isBrowser$1?logImageInBrowser$1({image:image,message:message,scale:scale}):logImageInNode$1({image:image,message:message,scale:scale});})},{key:"settings",value:function settings(){if(console.table){console.table(this._storage.config);}else{console.log(this._storage.config);}}},{key:"get",value:function get(setting){return this._storage.config[setting];}},{key:"set",value:function set(setting,value){this._storage.updateConfiguration(_defineProperty2({},setting,value));}},{key:"time",value:function time(logLevel,message){return this._getLogFunction(logLevel,message,console.time?console.time:console.info);}},{key:"timeEnd",value:function timeEnd(logLevel,message){return this._getLogFunction(logLevel,message,console.timeEnd?console.timeEnd:console.info);}},{key:"timeStamp",value:function timeStamp(logLevel,message){return this._getLogFunction(logLevel,message,console.timeStamp||noop$1);}},{key:"group",value:function group(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{collapsed:false};opts=normalizeArguments$1({logLevel:logLevel,message:message,opts:opts});var _opts=opts,collapsed=_opts.collapsed;opts.method=(collapsed?console.groupCollapsed:console.group)||console.info;return this._getLogFunction(opts);}},{key:"groupCollapsed",value:function groupCollapsed(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return this.group(logLevel,message,Object.assign({},opts,{collapsed:true}));}},{key:"groupEnd",value:function groupEnd(logLevel){return this._getLogFunction(logLevel,'',console.groupEnd||noop$1);}},{key:"withGroup",value:function withGroup(logLevel,message,func){this.group(logLevel,message)();try{func();}finally{this.groupEnd(logLevel)();}}},{key:"trace",value:function trace(){if(console.trace){console.trace();}}},{key:"_shouldLog",value:function _shouldLog(logLevel){return this.isEnabled()&&this.getLevel()>=normalizeLogLevel$1(logLevel);}},{key:"_getLogFunction",value:function _getLogFunction(logLevel,message,method){var args=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];var opts=arguments.length>4?arguments[4]:undefined;if(this._shouldLog(logLevel)){var _method;opts=normalizeArguments$1({logLevel:logLevel,message:message,args:args,opts:opts});method=method||opts.method;assert$3(method);opts.total=this.getTotal();opts.delta=this.getDelta();this._deltaTs=getHiResTimestamp$1();var tag=opts.tag||opts.message;if(opts.once){if(!cache$1[tag]){cache$1[tag]=getHiResTimestamp$1();}else{return noop$1;}}message=decorateMessage$1(this.id,opts.message,opts);return(_method=method).bind.apply(_method,[console,message].concat(_toConsumableArray(opts.args)));}return noop$1;}}]);return Log$1;}();Log$1.VERSION=VERSION$7;function normalizeLogLevel$1(logLevel){if(!logLevel){return 0;}var resolvedLevel;switch(_typeof(logLevel)){case'number':resolvedLevel=logLevel;break;case'object':resolvedLevel=logLevel.logLevel||logLevel.priority||0;break;default:return 0;}assert$3(Number.isFinite(resolvedLevel)&&resolvedLevel>=0);return resolvedLevel;}function normalizeArguments$1(opts){var logLevel=opts.logLevel,message=opts.message;opts.logLevel=normalizeLogLevel$1(logLevel);var args=opts.args?Array.from(opts.args):[];while(args.length&&args.shift()!==message){}opts.args=args;switch(_typeof(logLevel)){case'string':case'function':if(message!==undefined){args.unshift(message);}opts.message=logLevel;break;case'object':Object.assign(opts,logLevel);break;}if(typeof opts.message==='function'){opts.message=opts.message();}var messageType=_typeof(opts.message);assert$3(messageType==='string'||messageType==='object');return Object.assign(opts,opts.opts);}function decorateMessage$1(id,message,opts){if(typeof message==='string'){var _time=opts.time?leftPad$1(formatTime$1(opts.total)):'';message=opts.time?"".concat(id,": ").concat(_time," ").concat(message):"".concat(id,": ").concat(message);message=addColor$1(message,opts.color,opts.background);}return message;}function logImageInNode$1(_ref18){var image=_ref18.image,_ref18$message=_ref18.message,message=_ref18$message===void 0?'':_ref18$message,_ref18$scale=_ref18.scale,scale=_ref18$scale===void 0?1:_ref18$scale;var asciify=null;try{asciify=module.require('asciify-image');}catch(error){}if(asciify){return function(){return asciify(image,{fit:'box',width:"".concat(Math.round(80*scale),"%")}).then(function(data){return console.log(data);});};}return noop$1;}function logImageInBrowser$1(_ref19){var image=_ref19.image,_ref19$message=_ref19.message,message=_ref19$message===void 0?'':_ref19$message,_ref19$scale=_ref19.scale,scale=_ref19$scale===void 0?1:_ref19$scale;if(typeof image==='string'){var img=new Image();img.onload=function(){var _console;var args=formatImage$1(img,message,scale);(_console=console).log.apply(_console,_toConsumableArray(args));};img.src=image;return noop$1;}var element=image.nodeName||'';if(element.toLowerCase()==='img'){var _console2;(_console2=console).log.apply(_console2,_toConsumableArray(formatImage$1(image,message,scale)));return noop$1;}if(element.toLowerCase()==='canvas'){var _img=new Image();_img.onload=function(){var _console3;return(_console3=console).log.apply(_console3,_toConsumableArray(formatImage$1(_img,message,scale)));};_img.src=image.toDataURL();return noop$1;}return noop$1;}var probeLog=new Log$1({id:'loaders.gl'});var NullLog=/*#__PURE__*/function(){function NullLog(){_classCallCheck(this,NullLog);}_createClass(NullLog,[{key:"log",value:function log(){return function(){};}},{key:"info",value:function info(){return function(){};}},{key:"warn",value:function warn(){return function(){};}},{key:"error",value:function error(){return function(){};}}]);return NullLog;}();var ConsoleLog=/*#__PURE__*/function(){function ConsoleLog(){_classCallCheck(this,ConsoleLog);_defineProperty(this,"console",void 0);this.console=console;}_createClass(ConsoleLog,[{key:"log",value:function log(){var _this$console$log;for(var _len102=arguments.length,args=new Array(_len102),_key7=0;_key7<_len102;_key7++){args[_key7]=arguments[_key7];}return(_this$console$log=this.console.log).bind.apply(_this$console$log,[this.console].concat(args));}},{key:"info",value:function info(){var _this$console$info;for(var _len103=arguments.length,args=new Array(_len103),_key8=0;_key8<_len103;_key8++){args[_key8]=arguments[_key8];}return(_this$console$info=this.console.info).bind.apply(_this$console$info,[this.console].concat(args));}},{key:"warn",value:function warn(){var _this$console$warn;for(var _len104=arguments.length,args=new Array(_len104),_key9=0;_key9<_len104;_key9++){args[_key9]=arguments[_key9];}return(_this$console$warn=this.console.warn).bind.apply(_this$console$warn,[this.console].concat(args));}},{key:"error",value:function error(){var _this$console$error;for(var _len105=arguments.length,args=new Array(_len105),_key10=0;_key10<_len105;_key10++){args[_key10]=arguments[_key10];}return(_this$console$error=this.console.error).bind.apply(_this$console$error,[this.console].concat(args));}}]);return ConsoleLog;}();var DEFAULT_LOADER_OPTIONS={fetch:null,mimeType:undefined,nothrow:false,log:new ConsoleLog(),CDN:'https://unpkg.com/@loaders.gl',worker:true,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:isBrowser$4,_nodeWorkers:false,_workerType:'',limit:0,_limitMB:0,batchSize:'auto',batchDebounceMs:0,metadata:false,transforms:[]};var REMOVED_LOADER_OPTIONS={"throws":'nothrow',dataType:'(no longer used)',uri:'baseUri',method:'fetch.method',headers:'fetch.headers',body:'fetch.body',mode:'fetch.mode',credentials:'fetch.credentials',cache:'fetch.cache',redirect:'fetch.redirect',referrer:'fetch.referrer',referrerPolicy:'fetch.referrerPolicy',integrity:'fetch.integrity',keepalive:'fetch.keepalive',signal:'fetch.signal'};function getGlobalLoaderState(){globalThis.loaders=globalThis.loaders||{};var loaders=globalThis.loaders;loaders._state=loaders._state||{};return loaders._state;}var getGlobalLoaderOptions=function getGlobalLoaderOptions(){var state=getGlobalLoaderState();state.globalOptions=state.globalOptions||_objectSpread({},DEFAULT_LOADER_OPTIONS);return state.globalOptions;};function normalizeOptions(options,loader,loaders,url){loaders=loaders||[];loaders=Array.isArray(loaders)?loaders:[loaders];validateOptions(options,loaders);return normalizeOptionsInternal(loader,options,url);}function getFetchFunction(options,context){var globalOptions=getGlobalLoaderOptions();var fetchOptions=options||globalOptions;if(typeof fetchOptions.fetch==='function'){return fetchOptions.fetch;}if(isObject(fetchOptions.fetch)){return function(url){return fetchFile(url,fetchOptions);};}if(context!==null&&context!==void 0&&context.fetch){return context===null||context===void 0?void 0:context.fetch;}return fetchFile;}function validateOptions(options,loaders){validateOptionsObject(options,null,DEFAULT_LOADER_OPTIONS,REMOVED_LOADER_OPTIONS,loaders);var _iterator9=_createForOfIteratorHelper(loaders),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var loader=_step9.value;var idOptions=options&&options[loader.id]||{};var loaderOptions=loader.options&&loader.options[loader.id]||{};var deprecatedOptions=loader.deprecatedOptions&&loader.deprecatedOptions[loader.id]||{};validateOptionsObject(idOptions,loader.id,loaderOptions,deprecatedOptions,loaders);}}catch(err){_iterator9.e(err);}finally{_iterator9.f();}}function validateOptionsObject(options,id,defaultOptions,deprecatedOptions,loaders){var loaderName=id||'Top level';var prefix=id?"".concat(id,"."):'';for(var key in options){var isSubOptions=!id&&isObject(options[key]);var isBaseUriOption=key==='baseUri'&&!id;var isWorkerUrlOption=key==='workerUrl'&&id;if(!(key in defaultOptions)&&!isBaseUriOption&&!isWorkerUrlOption){if(key in deprecatedOptions){probeLog.warn("".concat(loaderName," loader option '").concat(prefix).concat(key,"' no longer supported, use '").concat(deprecatedOptions[key],"'"))();}else if(!isSubOptions){var suggestion=findSimilarOption(key,loaders);probeLog.warn("".concat(loaderName," loader option '").concat(prefix).concat(key,"' not recognized. ").concat(suggestion))();}}}}function findSimilarOption(optionKey,loaders){var lowerCaseOptionKey=optionKey.toLowerCase();var bestSuggestion='';var _iterator10=_createForOfIteratorHelper(loaders),_step10;try{for(_iterator10.s();!(_step10=_iterator10.n()).done;){var loader=_step10.value;for(var key in loader.options){if(optionKey===key){return"Did you mean '".concat(loader.id,".").concat(key,"'?");}var lowerCaseKey=key.toLowerCase();var isPartialMatch=lowerCaseOptionKey.startsWith(lowerCaseKey)||lowerCaseKey.startsWith(lowerCaseOptionKey);if(isPartialMatch){bestSuggestion=bestSuggestion||"Did you mean '".concat(loader.id,".").concat(key,"'?");}}}}catch(err){_iterator10.e(err);}finally{_iterator10.f();}return bestSuggestion;}function normalizeOptionsInternal(loader,options,url){var loaderDefaultOptions=loader.options||{};var mergedOptions=_objectSpread({},loaderDefaultOptions);addUrlOptions(mergedOptions,url);if(mergedOptions.log===null){mergedOptions.log=new NullLog();}mergeNestedFields(mergedOptions,getGlobalLoaderOptions());mergeNestedFields(mergedOptions,options);return mergedOptions;}function mergeNestedFields(mergedOptions,options){for(var key in options){if(key in options){var value=options[key];if(isPureObject(value)&&isPureObject(mergedOptions[key])){mergedOptions[key]=_objectSpread(_objectSpread({},mergedOptions[key]),options[key]);}else{mergedOptions[key]=options[key];}}}}function addUrlOptions(options,url){if(url&&!('baseUri'in options)){options.baseUri=url;}}function isLoaderObject(loader){var _loader;if(!loader){return false;}if(Array.isArray(loader)){loader=loader[0];}var hasExtensions=Array.isArray((_loader=loader)===null||_loader===void 0?void 0:_loader.extensions);return hasExtensions;}function normalizeLoader(loader){var _loader2,_loader3;assert$5(loader,'null loader');assert$5(isLoaderObject(loader),'invalid loader');var options;if(Array.isArray(loader)){options=loader[1];loader=loader[0];loader=_objectSpread(_objectSpread({},loader),{},{options:_objectSpread(_objectSpread({},loader.options),options)});}if((_loader2=loader)!==null&&_loader2!==void 0&&_loader2.parseTextSync||(_loader3=loader)!==null&&_loader3!==void 0&&_loader3.parseText){loader.text=true;}if(!loader.text){loader.binary=true;}return loader;}var getGlobalLoaderRegistry=function getGlobalLoaderRegistry(){var state=getGlobalLoaderState();state.loaderRegistry=state.loaderRegistry||[];return state.loaderRegistry;};function getRegisteredLoaders(){return getGlobalLoaderRegistry();}function isElectron(mockUserAgent){if(typeof window!=='undefined'&&_typeof(window.process)==='object'&&window.process.type==='renderer'){return true;}if(typeof process!=='undefined'&&_typeof(process.versions)==='object'&&Boolean(process.versions.electron)){return true;}var realUserAgent=(typeof navigator==="undefined"?"undefined":_typeof(navigator))==='object'&&typeof navigator.userAgent==='string'&&navigator.userAgent;var userAgent=mockUserAgent||realUserAgent;if(userAgent&&userAgent.indexOf('Electron')>=0){return true;}return false;}function isBrowser(){var isNode=(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&String(process)==='[object process]'&&!process.browser;return!isNode||isElectron();}var globals={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document,process:(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&process};var window_=globals.window||globals.self||globals.global;var process_=globals.process||{};var VERSION$6=typeof __VERSION__!=='undefined'?__VERSION__:'untranspiled source';isBrowser();function getStorage(type){try{var storage=window[type];var x='__storage_test__';storage.setItem(x,x);storage.removeItem(x);return storage;}catch(e){return null;}}var LocalStorage=/*#__PURE__*/function(){function LocalStorage(id){_classCallCheck(this,LocalStorage);var defaultSettings=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'sessionStorage';_defineProperty(this,"storage",void 0);_defineProperty(this,"id",void 0);_defineProperty(this,"config",{});this.storage=getStorage(type);this.id=id;this.config={};Object.assign(this.config,defaultSettings);this._loadConfiguration();}_createClass(LocalStorage,[{key:"getConfiguration",value:function getConfiguration(){return this.config;}},{key:"setConfiguration",value:function setConfiguration(configuration){this.config={};return this.updateConfiguration(configuration);}},{key:"updateConfiguration",value:function updateConfiguration(configuration){Object.assign(this.config,configuration);if(this.storage){var serialized=JSON.stringify(this.config);this.storage.setItem(this.id,serialized);}return this;}},{key:"_loadConfiguration",value:function _loadConfiguration(){var configuration={};if(this.storage){var serializedConfiguration=this.storage.getItem(this.id);configuration=serializedConfiguration?JSON.parse(serializedConfiguration):{};}Object.assign(this.config,configuration);return this;}}]);return LocalStorage;}();function formatTime(ms){var formatted;if(ms<10){formatted="".concat(ms.toFixed(2),"ms");}else if(ms<100){formatted="".concat(ms.toFixed(1),"ms");}else if(ms<1000){formatted="".concat(ms.toFixed(0),"ms");}else{formatted="".concat((ms/1000).toFixed(2),"s");}return formatted;}function leftPad(string){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:8;var padLength=Math.max(length-string.length,0);return"".concat(' '.repeat(padLength)).concat(string);}function formatImage(image,message,scale){var maxWidth=arguments.length>3&&arguments[3]!==undefined?arguments[3]:600;var imageUrl=image.src.replace(/\(/g,'%28').replace(/\)/g,'%29');if(image.width>maxWidth){scale=Math.min(scale,maxWidth/image.width);}var width=image.width*scale;var height=image.height*scale;var style=['font-size:1px;',"padding:".concat(Math.floor(height/2),"px ").concat(Math.floor(width/2),"px;"),"line-height:".concat(height,"px;"),"background:url(".concat(imageUrl,");"),"background-size:".concat(width,"px ").concat(height,"px;"),'color:transparent;'].join('');return["".concat(message," %c+"),style];}var COLOR;(function(COLOR){COLOR[COLOR["BLACK"]=30]="BLACK";COLOR[COLOR["RED"]=31]="RED";COLOR[COLOR["GREEN"]=32]="GREEN";COLOR[COLOR["YELLOW"]=33]="YELLOW";COLOR[COLOR["BLUE"]=34]="BLUE";COLOR[COLOR["MAGENTA"]=35]="MAGENTA";COLOR[COLOR["CYAN"]=36]="CYAN";COLOR[COLOR["WHITE"]=37]="WHITE";COLOR[COLOR["BRIGHT_BLACK"]=90]="BRIGHT_BLACK";COLOR[COLOR["BRIGHT_RED"]=91]="BRIGHT_RED";COLOR[COLOR["BRIGHT_GREEN"]=92]="BRIGHT_GREEN";COLOR[COLOR["BRIGHT_YELLOW"]=93]="BRIGHT_YELLOW";COLOR[COLOR["BRIGHT_BLUE"]=94]="BRIGHT_BLUE";COLOR[COLOR["BRIGHT_MAGENTA"]=95]="BRIGHT_MAGENTA";COLOR[COLOR["BRIGHT_CYAN"]=96]="BRIGHT_CYAN";COLOR[COLOR["BRIGHT_WHITE"]=97]="BRIGHT_WHITE";})(COLOR||(COLOR={}));function getColor(color){return typeof color==='string'?COLOR[color.toUpperCase()]||COLOR.WHITE:color;}function addColor(string,color,background){if(!isBrowser&&typeof string==='string'){if(color){color=getColor(color);string="\x1B[".concat(color,"m").concat(string,"\x1B[39m");}if(background){color=getColor(background);string="\x1B[".concat(background+10,"m").concat(string,"\x1B[49m");}}return string;}function autobind(obj){var predefined=arguments.length>1&&arguments[1]!==undefined?arguments[1]:['constructor'];var proto=Object.getPrototypeOf(obj);var propNames=Object.getOwnPropertyNames(proto);var _iterator11=_createForOfIteratorHelper(propNames),_step11;try{var _loop5=function _loop5(){var key=_step11.value;if(typeof obj[key]==='function'){if(!predefined.find(function(name){return key===name;})){obj[key]=obj[key].bind(obj);}}};for(_iterator11.s();!(_step11=_iterator11.n()).done;){_loop5();}}catch(err){_iterator11.e(err);}finally{_iterator11.f();}}function assert$2(condition,message){if(!condition){throw new Error(message||'Assertion failed');}}function getHiResTimestamp(){var timestamp;if(isBrowser&&'performance'in window_){var _window$performance,_window$performance$n;timestamp=window_===null||window_===void 0?void 0:(_window$performance=window_.performance)===null||_window$performance===void 0?void 0:(_window$performance$n=_window$performance.now)===null||_window$performance$n===void 0?void 0:_window$performance$n.call(_window$performance);}else if('hrtime'in process_){var _process$hrtime;var timeParts=process_===null||process_===void 0?void 0:(_process$hrtime=process_.hrtime)===null||_process$hrtime===void 0?void 0:_process$hrtime.call(process_);timestamp=timeParts[0]*1000+timeParts[1]/1e6;}else{timestamp=Date.now();}return timestamp;}var originalConsole={debug:isBrowser?console.debug||console.log:console.log,log:console.log,info:console.info,warn:console.warn,error:console.error};var DEFAULT_SETTINGS={enabled:true,level:0};function noop(){}var cache={};var ONCE={once:true};var Log=/*#__PURE__*/function(){function Log(){_classCallCheck(this,Log);var _ref20=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{id:''},id=_ref20.id;_defineProperty(this,"id",void 0);_defineProperty(this,"VERSION",VERSION$6);_defineProperty(this,"_startTs",getHiResTimestamp());_defineProperty(this,"_deltaTs",getHiResTimestamp());_defineProperty(this,"_storage",void 0);_defineProperty(this,"userData",{});_defineProperty(this,"LOG_THROTTLE_TIMEOUT",0);this.id=id;this._storage=new LocalStorage("__probe-".concat(this.id,"__"),DEFAULT_SETTINGS);this.userData={};this.timeStamp("".concat(this.id," started"));autobind(this);Object.seal(this);}_createClass(Log,[{key:"level",get:function get(){return this.getLevel();},set:function set(newLevel){this.setLevel(newLevel);}},{key:"isEnabled",value:function isEnabled(){return this._storage.config.enabled;}},{key:"getLevel",value:function getLevel(){return this._storage.config.level;}},{key:"getTotal",value:function getTotal(){return Number((getHiResTimestamp()-this._startTs).toPrecision(10));}},{key:"getDelta",value:function getDelta(){return Number((getHiResTimestamp()-this._deltaTs).toPrecision(10));}},{key:"priority",get:function get(){return this.level;},set:function set(newPriority){this.level=newPriority;}},{key:"getPriority",value:function getPriority(){return this.level;}},{key:"enable",value:function enable(){var enabled=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;this._storage.updateConfiguration({enabled:enabled});return this;}},{key:"setLevel",value:function setLevel(level){this._storage.updateConfiguration({level:level});return this;}},{key:"get",value:function get(setting){return this._storage.config[setting];}},{key:"set",value:function set(setting,value){this._storage.updateConfiguration(_defineProperty2({},setting,value));}},{key:"settings",value:function settings(){if(console.table){console.table(this._storage.config);}else{console.log(this._storage.config);}}},{key:"assert",value:function assert(condition,message){assert$2(condition,message);}},{key:"warn",value:function warn(message){return this._getLogFunction(0,message,originalConsole.warn,arguments,ONCE);}},{key:"error",value:function error(message){return this._getLogFunction(0,message,originalConsole.error,arguments);}},{key:"deprecated",value:function deprecated(oldUsage,newUsage){return this.warn("`".concat(oldUsage,"` is deprecated and will be removed in a later version. Use `").concat(newUsage,"` instead"));}},{key:"removed",value:function removed(oldUsage,newUsage){return this.error("`".concat(oldUsage,"` has been removed. Use `").concat(newUsage,"` instead"));}},{key:"probe",value:function probe(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole.log,arguments,{time:true,once:true});}},{key:"log",value:function log(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole.debug,arguments);}},{key:"info",value:function info(logLevel,message){return this._getLogFunction(logLevel,message,console.info,arguments);}},{key:"once",value:function once(logLevel,message){for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key];}return this._getLogFunction(logLevel,message,originalConsole.debug||originalConsole.info,arguments,ONCE);}},{key:"table",value:function table(logLevel,_table2,columns){if(_table2){return this._getLogFunction(logLevel,_table2,console.table||noop,columns&&[columns],{tag:getTableHeader(_table2)});}return noop;}},{key:"image",value:function image(_ref){var logLevel=_ref.logLevel,priority=_ref.priority,image=_ref.image,_ref$message=_ref.message,message=_ref$message===void 0?'':_ref$message,_ref$scale=_ref.scale,scale=_ref$scale===void 0?1:_ref$scale;if(!this._shouldLog(logLevel||priority)){return noop;}return isBrowser?logImageInBrowser({image:image,message:message,scale:scale}):logImageInNode({image:image,message:message,scale:scale});}},{key:"time",value:function time(logLevel,message){return this._getLogFunction(logLevel,message,console.time?console.time:console.info);}},{key:"timeEnd",value:function timeEnd(logLevel,message){return this._getLogFunction(logLevel,message,console.timeEnd?console.timeEnd:console.info);}},{key:"timeStamp",value:function timeStamp(logLevel,message){return this._getLogFunction(logLevel,message,console.timeStamp||noop);}},{key:"group",value:function group(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{collapsed:false};var options=normalizeArguments({logLevel:logLevel,message:message,opts:opts});var collapsed=opts.collapsed;options.method=(collapsed?console.groupCollapsed:console.group)||console.info;return this._getLogFunction(options);}},{key:"groupCollapsed",value:function groupCollapsed(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return this.group(logLevel,message,Object.assign({},opts,{collapsed:true}));}},{key:"groupEnd",value:function groupEnd(logLevel){return this._getLogFunction(logLevel,'',console.groupEnd||noop);}},{key:"withGroup",value:function withGroup(logLevel,message,func){this.group(logLevel,message)();try{func();}finally{this.groupEnd(logLevel)();}}},{key:"trace",value:function trace(){if(console.trace){console.trace();}}},{key:"_shouldLog",value:function _shouldLog(logLevel){return this.isEnabled()&&this.getLevel()>=normalizeLogLevel(logLevel);}},{key:"_getLogFunction",value:function _getLogFunction(logLevel,message,method,args,opts){if(this._shouldLog(logLevel)){var _method2;opts=normalizeArguments({logLevel:logLevel,message:message,args:args,opts:opts});method=method||opts.method;assert$2(method);opts.total=this.getTotal();opts.delta=this.getDelta();this._deltaTs=getHiResTimestamp();var tag=opts.tag||opts.message;if(opts.once){if(!cache[tag]){cache[tag]=getHiResTimestamp();}else{return noop;}}message=decorateMessage(this.id,opts.message,opts);return(_method2=method).bind.apply(_method2,[console,message].concat(_toConsumableArray(opts.args)));}return noop;}}]);return Log;}();_defineProperty(Log,"VERSION",VERSION$6);function normalizeLogLevel(logLevel){if(!logLevel){return 0;}var resolvedLevel;switch(_typeof(logLevel)){case'number':resolvedLevel=logLevel;break;case'object':resolvedLevel=logLevel.logLevel||logLevel.priority||0;break;default:return 0;}assert$2(Number.isFinite(resolvedLevel)&&resolvedLevel>=0);return resolvedLevel;}function normalizeArguments(opts){var logLevel=opts.logLevel,message=opts.message;opts.logLevel=normalizeLogLevel(logLevel);var args=opts.args?Array.from(opts.args):[];while(args.length&&args.shift()!==message){}switch(_typeof(logLevel)){case'string':case'function':if(message!==undefined){args.unshift(message);}opts.message=logLevel;break;case'object':Object.assign(opts,logLevel);break;}if(typeof opts.message==='function'){opts.message=opts.message();}var messageType=_typeof(opts.message);assert$2(messageType==='string'||messageType==='object');return Object.assign(opts,{args:args},opts.opts);}function decorateMessage(id,message,opts){if(typeof message==='string'){var _time2=opts.time?leftPad(formatTime(opts.total)):'';message=opts.time?"".concat(id,": ").concat(_time2," ").concat(message):"".concat(id,": ").concat(message);message=addColor(message,opts.color,opts.background);}return message;}function logImageInNode(_ref2){var image=_ref2.image,_ref2$message=_ref2.message,message=_ref2$message===void 0?'':_ref2$message,_ref2$scale=_ref2.scale,scale=_ref2$scale===void 0?1:_ref2$scale;var asciify=null;try{asciify=module.require('asciify-image');}catch(error){}if(asciify){return function(){return asciify(image,{fit:'box',width:"".concat(Math.round(80*scale),"%")}).then(function(data){return console.log(data);});};}return noop;}function logImageInBrowser(_ref3){var image=_ref3.image,_ref3$message=_ref3.message,message=_ref3$message===void 0?'':_ref3$message,_ref3$scale=_ref3.scale,scale=_ref3$scale===void 0?1:_ref3$scale;if(typeof image==='string'){var img=new Image();img.onload=function(){var _console4;var args=formatImage(img,message,scale);(_console4=console).log.apply(_console4,_toConsumableArray(args));};img.src=image;return noop;}var element=image.nodeName||'';if(element.toLowerCase()==='img'){var _console5;(_console5=console).log.apply(_console5,_toConsumableArray(formatImage(image,message,scale)));return noop;}if(element.toLowerCase()==='canvas'){var _img2=new Image();_img2.onload=function(){var _console6;return(_console6=console).log.apply(_console6,_toConsumableArray(formatImage(_img2,message,scale)));};_img2.src=image.toDataURL();return noop;}return noop;}function getTableHeader(table){for(var key in table){for(var title in table[key]){return title||'untitled';}}return'empty';}var log=new Log({id:'loaders.gl'});var EXT_PATTERN=/\.([^.]+)$/;function selectLoader(_x27){return _selectLoader.apply(this,arguments);}function _selectLoader(){_selectLoader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(data){var loaders,options,context,loader,_args16=arguments;return _regeneratorRuntime().wrap(function _callee18$(_context22){while(1){switch(_context22.prev=_context22.next){case 0:loaders=_args16.length>1&&_args16[1]!==undefined?_args16[1]:[];options=_args16.length>2?_args16[2]:undefined;context=_args16.length>3?_args16[3]:undefined;if(validHTTPResponse(data)){_context22.next=5;break;}return _context22.abrupt("return",null);case 5:loader=selectLoaderSync(data,loaders,_objectSpread(_objectSpread({},options),{},{nothrow:true}),context);if(!loader){_context22.next=8;break;}return _context22.abrupt("return",loader);case 8:if(!isBlob(data)){_context22.next=13;break;}_context22.next=11;return data.slice(0,10).arrayBuffer();case 11:data=_context22.sent;loader=selectLoaderSync(data,loaders,options,context);case 13:if(!(!loader&&!(options!==null&&options!==void 0&&options.nothrow))){_context22.next=15;break;}throw new Error(getNoValidLoaderMessage(data));case 15:return _context22.abrupt("return",loader);case 16:case"end":return _context22.stop();}}},_callee18);}));return _selectLoader.apply(this,arguments);}function selectLoaderSync(data){var loaders=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var options=arguments.length>2?arguments[2]:undefined;var context=arguments.length>3?arguments[3]:undefined;if(!validHTTPResponse(data)){return null;}if(loaders&&!Array.isArray(loaders)){return normalizeLoader(loaders);}var candidateLoaders=[];if(loaders){candidateLoaders=candidateLoaders.concat(loaders);}if(!(options!==null&&options!==void 0&&options.ignoreRegisteredLoaders)){var _candidateLoaders;(_candidateLoaders=candidateLoaders).push.apply(_candidateLoaders,_toConsumableArray(getRegisteredLoaders()));}normalizeLoaders(candidateLoaders);var loader=selectLoaderInternal(data,candidateLoaders,options,context);if(!loader&&!(options!==null&&options!==void 0&&options.nothrow)){throw new Error(getNoValidLoaderMessage(data));}return loader;}function selectLoaderInternal(data,loaders,options,context){var _getResourceUrlAndTyp=getResourceUrlAndType(data),url=_getResourceUrlAndTyp.url,type=_getResourceUrlAndTyp.type;var testUrl=url||(context===null||context===void 0?void 0:context.url);var loader=null;var reason='';if(options!==null&&options!==void 0&&options.mimeType){loader=findLoaderByMIMEType(loaders,options===null||options===void 0?void 0:options.mimeType);reason="match forced by supplied MIME type ".concat(options===null||options===void 0?void 0:options.mimeType);}loader=loader||findLoaderByUrl(loaders,testUrl);reason=reason||(loader?"matched url ".concat(testUrl):'');loader=loader||findLoaderByMIMEType(loaders,type);reason=reason||(loader?"matched MIME type ".concat(type):'');loader=loader||findLoaderByInitialBytes(loaders,data);reason=reason||(loader?"matched initial data ".concat(getFirstCharacters(data)):'');loader=loader||findLoaderByMIMEType(loaders,options===null||options===void 0?void 0:options.fallbackMimeType);reason=reason||(loader?"matched fallback MIME type ".concat(type):'');if(reason){var _loader;log.log(1,"selectLoader selected ".concat((_loader=loader)===null||_loader===void 0?void 0:_loader.name,": ").concat(reason,"."));}return loader;}function validHTTPResponse(data){if(data instanceof Response){if(data.status===204){return false;}}return true;}function getNoValidLoaderMessage(data){var _getResourceUrlAndTyp2=getResourceUrlAndType(data),url=_getResourceUrlAndTyp2.url,type=_getResourceUrlAndTyp2.type;var message='No valid loader found (';message+=url?"".concat(filename(url),", "):'no url provided, ';message+="MIME type: ".concat(type?"\"".concat(type,"\""):'not provided',", ");var firstCharacters=data?getFirstCharacters(data):'';message+=firstCharacters?" first bytes: \"".concat(firstCharacters,"\""):'first bytes: not available';message+=')';return message;}function normalizeLoaders(loaders){var _iterator12=_createForOfIteratorHelper(loaders),_step12;try{for(_iterator12.s();!(_step12=_iterator12.n()).done;){var loader=_step12.value;normalizeLoader(loader);}}catch(err){_iterator12.e(err);}finally{_iterator12.f();}}function findLoaderByUrl(loaders,url){var match=url&&EXT_PATTERN.exec(url);var extension=match&&match[1];return extension?findLoaderByExtension(loaders,extension):null;}function findLoaderByExtension(loaders,extension){extension=extension.toLowerCase();var _iterator13=_createForOfIteratorHelper(loaders),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var loader=_step13.value;var _iterator14=_createForOfIteratorHelper(loader.extensions),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var loaderExtension=_step14.value;if(loaderExtension.toLowerCase()===extension){return loader;}}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}return null;}function findLoaderByMIMEType(loaders,mimeType){var _iterator15=_createForOfIteratorHelper(loaders),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var loader=_step15.value;if(loader.mimeTypes&&loader.mimeTypes.includes(mimeType)){return loader;}if(mimeType==="application/x.".concat(loader.id)){return loader;}}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}return null;}function findLoaderByInitialBytes(loaders,data){if(!data){return null;}var _iterator16=_createForOfIteratorHelper(loaders),_step16;try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){var loader=_step16.value;if(typeof data==='string'){if(testDataAgainstText(data,loader)){return loader;}}else if(ArrayBuffer.isView(data)){if(testDataAgainstBinary(data.buffer,data.byteOffset,loader)){return loader;}}else if(data instanceof ArrayBuffer){var byteOffset=0;if(testDataAgainstBinary(data,byteOffset,loader)){return loader;}}}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}return null;}function testDataAgainstText(data,loader){if(loader.testText){return loader.testText(data);}var tests=Array.isArray(loader.tests)?loader.tests:[loader.tests];return tests.some(function(test){return data.startsWith(test);});}function testDataAgainstBinary(data,byteOffset,loader){var tests=Array.isArray(loader.tests)?loader.tests:[loader.tests];return tests.some(function(test){return testBinary(data,byteOffset,loader,test);});}function testBinary(data,byteOffset,loader,test){if(test instanceof ArrayBuffer){return compareArrayBuffers(test,data,test.byteLength);}switch(_typeof(test)){case'function':return test(data,loader);case'string':var magic=getMagicString$1(data,byteOffset,test.length);return test===magic;default:return false;}}function getFirstCharacters(data){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5;if(typeof data==='string'){return data.slice(0,length);}else if(ArrayBuffer.isView(data)){return getMagicString$1(data.buffer,data.byteOffset,length);}else if(data instanceof ArrayBuffer){var byteOffset=0;return getMagicString$1(data,byteOffset,length);}return'';}function getMagicString$1(arrayBuffer,byteOffset,length){if(arrayBuffer.byteLength<byteOffset+length){return'';}var dataView=new DataView(arrayBuffer);var magic='';for(var _i513=0;_i513<length;_i513++){magic+=String.fromCharCode(dataView.getUint8(byteOffset+_i513));}return magic;}var DEFAULT_CHUNK_SIZE$2=256*1024;function makeStringIterator(string,options){var chunkSize,offset,textEncoder,chunkLength,chunk;return _regeneratorRuntime().wrap(function makeStringIterator$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:chunkSize=(options===null||options===void 0?void 0:options.chunkSize)||DEFAULT_CHUNK_SIZE$2;offset=0;textEncoder=new TextEncoder();case 3:if(!(offset<string.length)){_context5.next=11;break;}chunkLength=Math.min(string.length-offset,chunkSize);chunk=string.slice(offset,offset+chunkLength);offset+=chunkLength;_context5.next=9;return textEncoder.encode(chunk);case 9:_context5.next=3;break;case 11:case"end":return _context5.stop();}}},_marked);}var DEFAULT_CHUNK_SIZE$1=256*1024;function makeArrayBufferIterator(arrayBuffer){var options,_options$chunkSize,chunkSize,byteOffset,chunkByteLength,chunk,sourceArray,_chunkArray,_args5=arguments;return _regeneratorRuntime().wrap(function makeArrayBufferIterator$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:options=_args5.length>1&&_args5[1]!==undefined?_args5[1]:{};_options$chunkSize=options.chunkSize,chunkSize=_options$chunkSize===void 0?DEFAULT_CHUNK_SIZE$1:_options$chunkSize;byteOffset=0;case 3:if(!(byteOffset<arrayBuffer.byteLength)){_context6.next=14;break;}chunkByteLength=Math.min(arrayBuffer.byteLength-byteOffset,chunkSize);chunk=new ArrayBuffer(chunkByteLength);sourceArray=new Uint8Array(arrayBuffer,byteOffset,chunkByteLength);_chunkArray=new Uint8Array(chunk);_chunkArray.set(sourceArray);byteOffset+=chunkByteLength;_context6.next=12;return chunk;case 12:_context6.next=3;break;case 14:case"end":return _context6.stop();}}},_marked2);}var DEFAULT_CHUNK_SIZE=1024*1024;function makeBlobIterator(_x,_x2){return _makeBlobIterator.apply(this,arguments);}function _makeBlobIterator(){_makeBlobIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(blob,options){var chunkSize,offset,end,chunk;return _regeneratorRuntime().wrap(function _callee4$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:chunkSize=(options===null||options===void 0?void 0:options.chunkSize)||DEFAULT_CHUNK_SIZE;offset=0;case 2:if(!(offset<blob.size)){_context7.next=12;break;}end=offset+chunkSize;_context7.next=6;return _awaitAsyncGenerator(blob.slice(offset,end).arrayBuffer());case 6:chunk=_context7.sent;offset=end;_context7.next=10;return chunk;case 10:_context7.next=2;break;case 12:case"end":return _context7.stop();}}},_callee4);}));return _makeBlobIterator.apply(this,arguments);}function makeStreamIterator(stream,options){return isBrowser$4?makeBrowserStreamIterator(stream,options):makeNodeStreamIterator(stream);}function makeBrowserStreamIterator(_x3,_x4){return _makeBrowserStreamIterator.apply(this,arguments);}function _makeBrowserStreamIterator(){_makeBrowserStreamIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(stream,options){var reader,nextBatchPromise,currentBatchPromise,_yield$_awaitAsyncGen,done,value;return _regeneratorRuntime().wrap(function _callee5$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:reader=stream.getReader();_context8.prev=1;case 2:if(!true){_context8.next=16;break;}currentBatchPromise=nextBatchPromise||reader.read();if(options!==null&&options!==void 0&&options._streamReadAhead){nextBatchPromise=reader.read();}_context8.next=7;return _awaitAsyncGenerator(currentBatchPromise);case 7:_yield$_awaitAsyncGen=_context8.sent;done=_yield$_awaitAsyncGen.done;value=_yield$_awaitAsyncGen.value;if(!done){_context8.next=12;break;}return _context8.abrupt("return");case 12:_context8.next=14;return toArrayBuffer(value);case 14:_context8.next=2;break;case 16:_context8.next=21;break;case 18:_context8.prev=18;_context8.t0=_context8["catch"](1);reader.releaseLock();case 21:case"end":return _context8.stop();}}},_callee5,null,[[1,18]]);}));return _makeBrowserStreamIterator.apply(this,arguments);}function makeNodeStreamIterator(_x5,_x6){return _makeNodeStreamIterator.apply(this,arguments);}function _makeNodeStreamIterator(){_makeNodeStreamIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(stream,options){var _iteratorAbruptCompletion2,_didIteratorError2,_iteratorError2,_iterator2,_step2,chunk;return _regeneratorRuntime().wrap(function _callee6$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:_iteratorAbruptCompletion2=false;_didIteratorError2=false;_context9.prev=2;_iterator2=_asyncIterator(stream);case 4:_context9.next=6;return _awaitAsyncGenerator(_iterator2.next());case 6:if(!(_iteratorAbruptCompletion2=!(_step2=_context9.sent).done)){_context9.next=13;break;}chunk=_step2.value;_context9.next=10;return toArrayBuffer(chunk);case 10:_iteratorAbruptCompletion2=false;_context9.next=4;break;case 13:_context9.next=19;break;case 15:_context9.prev=15;_context9.t0=_context9["catch"](2);_didIteratorError2=true;_iteratorError2=_context9.t0;case 19:_context9.prev=19;_context9.prev=20;if(!(_iteratorAbruptCompletion2&&_iterator2["return"]!=null)){_context9.next=24;break;}_context9.next=24;return _awaitAsyncGenerator(_iterator2["return"]());case 24:_context9.prev=24;if(!_didIteratorError2){_context9.next=27;break;}throw _iteratorError2;case 27:return _context9.finish(24);case 28:return _context9.finish(19);case 29:case"end":return _context9.stop();}}},_callee6,null,[[2,15,19,29],[20,,24,28]]);}));return _makeNodeStreamIterator.apply(this,arguments);}function makeIterator(data,options){if(typeof data==='string'){return makeStringIterator(data,options);}if(data instanceof ArrayBuffer){return makeArrayBufferIterator(data,options);}if(isBlob(data)){return makeBlobIterator(data,options);}if(isReadableStream(data)){return makeStreamIterator(data,options);}if(isResponse(data)){var response=data;return makeStreamIterator(response.body,options);}throw new Error('makeIterator');}var ERR_DATA='Cannot convert supplied data type';function getArrayBufferOrStringFromDataSync(data,loader,options){if(loader.text&&typeof data==='string'){return data;}if(isBuffer(data)){data=data.buffer;}if(data instanceof ArrayBuffer){var arrayBuffer=data;if(loader.text&&!loader.binary){var textDecoder=new TextDecoder('utf8');return textDecoder.decode(arrayBuffer);}return arrayBuffer;}if(ArrayBuffer.isView(data)){if(loader.text&&!loader.binary){var _textDecoder=new TextDecoder('utf8');return _textDecoder.decode(data);}var _arrayBuffer=data.buffer;var byteLength=data.byteLength||data.length;if(data.byteOffset!==0||byteLength!==_arrayBuffer.byteLength){_arrayBuffer=_arrayBuffer.slice(data.byteOffset,data.byteOffset+byteLength);}return _arrayBuffer;}throw new Error(ERR_DATA);}function getArrayBufferOrStringFromData(_x28,_x29,_x30){return _getArrayBufferOrStringFromData.apply(this,arguments);}function _getArrayBufferOrStringFromData(){_getArrayBufferOrStringFromData=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data,loader,options){var isArrayBuffer,response;return _regeneratorRuntime().wrap(function _callee19$(_context23){while(1){switch(_context23.prev=_context23.next){case 0:isArrayBuffer=data instanceof ArrayBuffer||ArrayBuffer.isView(data);if(!(typeof data==='string'||isArrayBuffer)){_context23.next=3;break;}return _context23.abrupt("return",getArrayBufferOrStringFromDataSync(data,loader));case 3:if(!isBlob(data)){_context23.next=7;break;}_context23.next=6;return makeResponse(data);case 6:data=_context23.sent;case 7:if(!isResponse(data)){_context23.next=21;break;}response=data;_context23.next=11;return checkResponse(response);case 11:if(!loader.binary){_context23.next=17;break;}_context23.next=14;return response.arrayBuffer();case 14:_context23.t0=_context23.sent;_context23.next=20;break;case 17:_context23.next=19;return response.text();case 19:_context23.t0=_context23.sent;case 20:return _context23.abrupt("return",_context23.t0);case 21:if(isReadableStream(data)){data=makeIterator(data,options);}if(!(isIterable(data)||isAsyncIterable(data))){_context23.next=24;break;}return _context23.abrupt("return",concatenateArrayBuffersAsync(data));case 24:throw new Error(ERR_DATA);case 25:case"end":return _context23.stop();}}},_callee19);}));return _getArrayBufferOrStringFromData.apply(this,arguments);}function getLoaderContext(context,options){var previousContext=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(previousContext){return previousContext;}var resolvedContext=_objectSpread({fetch:getFetchFunction(options,context)},context);if(!Array.isArray(resolvedContext.loaders)){resolvedContext.loaders=null;}return resolvedContext;}function getLoadersFromContext(loaders,context){if(!context&&loaders&&!Array.isArray(loaders)){return loaders;}var candidateLoaders;if(loaders){candidateLoaders=Array.isArray(loaders)?loaders:[loaders];}if(context&&context.loaders){var contextLoaders=Array.isArray(context.loaders)?context.loaders:[context.loaders];candidateLoaders=candidateLoaders?[].concat(_toConsumableArray(candidateLoaders),_toConsumableArray(contextLoaders)):contextLoaders;}return candidateLoaders&&candidateLoaders.length?candidateLoaders:null;}function parse$3(_x31,_x32,_x33,_x34){return _parse$.apply(this,arguments);}function _parse$(){_parse$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(data,loaders,options,context){var _getResourceUrlAndTyp4,url,typedLoaders,candidateLoaders,loader;return _regeneratorRuntime().wrap(function _callee20$(_context24){while(1){switch(_context24.prev=_context24.next){case 0:assert$4(!context||_typeof(context)==='object');if(loaders&&!Array.isArray(loaders)&&!isLoaderObject(loaders)){context=undefined;options=loaders;loaders=undefined;}_context24.next=4;return data;case 4:data=_context24.sent;options=options||{};_getResourceUrlAndTyp4=getResourceUrlAndType(data),url=_getResourceUrlAndTyp4.url;typedLoaders=loaders;candidateLoaders=getLoadersFromContext(typedLoaders,context);_context24.next=11;return selectLoader(data,candidateLoaders,options);case 11:loader=_context24.sent;if(loader){_context24.next=14;break;}return _context24.abrupt("return",null);case 14:options=normalizeOptions(options,loader,candidateLoaders,url);context=getLoaderContext({url:url,parse:parse$3,loaders:candidateLoaders},options,context);_context24.next=18;return parseWithLoader(loader,data,options,context);case 18:return _context24.abrupt("return",_context24.sent);case 19:case"end":return _context24.stop();}}},_callee20);}));return _parse$.apply(this,arguments);}function parseWithLoader(_x35,_x36,_x37,_x38){return _parseWithLoader.apply(this,arguments);}function _parseWithLoader(){_parseWithLoader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(loader,data,options,context){var response,ok,redirected,status,statusText,type,url,headers;return _regeneratorRuntime().wrap(function _callee21$(_context25){while(1){switch(_context25.prev=_context25.next){case 0:validateWorkerVersion(loader);if(isResponse(data)){response=data;ok=response.ok,redirected=response.redirected,status=response.status,statusText=response.statusText,type=response.type,url=response.url;headers=Object.fromEntries(response.headers.entries());context.response={headers:headers,ok:ok,redirected:redirected,status:status,statusText:statusText,type:type,url:url};}_context25.next=4;return getArrayBufferOrStringFromData(data,loader,options);case 4:data=_context25.sent;if(!(loader.parseTextSync&&typeof data==='string')){_context25.next=8;break;}options.dataType='text';return _context25.abrupt("return",loader.parseTextSync(data,options,context,loader));case 8:if(!canParseWithWorker(loader,options)){_context25.next=12;break;}_context25.next=11;return parseWithWorker(loader,data,options,context,parse$3);case 11:return _context25.abrupt("return",_context25.sent);case 12:if(!(loader.parseText&&typeof data==='string')){_context25.next=16;break;}_context25.next=15;return loader.parseText(data,options,context,loader);case 15:return _context25.abrupt("return",_context25.sent);case 16:if(!loader.parse){_context25.next=20;break;}_context25.next=19;return loader.parse(data,options,context,loader);case 19:return _context25.abrupt("return",_context25.sent);case 20:assert$4(!loader.parseSync);throw new Error("".concat(loader.id," loader - no parser found and worker is disabled"));case 22:case"end":return _context25.stop();}}},_callee21);}));return _parseWithLoader.apply(this,arguments);}var VERSION$5="3.2.6";var VERSION$4="3.2.6";var VERSION$3="3.2.6";var BASIS_CDN_ENCODER_WASM="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$3,"/dist/libs/basis_encoder.wasm");var BASIS_CDN_ENCODER_JS="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$3,"/dist/libs/basis_encoder.js");var loadBasisTranscoderPromise;function loadBasisTrascoderModule(_x39){return _loadBasisTrascoderModule.apply(this,arguments);}function _loadBasisTrascoderModule(){_loadBasisTrascoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(options){var modules;return _regeneratorRuntime().wrap(function _callee22$(_context26){while(1){switch(_context26.prev=_context26.next){case 0:modules=options.modules||{};if(!modules.basis){_context26.next=3;break;}return _context26.abrupt("return",modules.basis);case 3:loadBasisTranscoderPromise=loadBasisTranscoderPromise||loadBasisTrascoder(options);_context26.next=6;return loadBasisTranscoderPromise;case 6:return _context26.abrupt("return",_context26.sent);case 7:case"end":return _context26.stop();}}},_callee22);}));return _loadBasisTrascoderModule.apply(this,arguments);}function loadBasisTrascoder(_x40){return _loadBasisTrascoder.apply(this,arguments);}function _loadBasisTrascoder(){_loadBasisTrascoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(options){var BASIS,wasmBinary,_yield$Promise$all,_yield$Promise$all2;return _regeneratorRuntime().wrap(function _callee23$(_context27){while(1){switch(_context27.prev=_context27.next){case 0:BASIS=null;wasmBinary=null;_context27.t0=Promise;_context27.next=5;return loadLibrary('basis_transcoder.js','textures',options);case 5:_context27.t1=_context27.sent;_context27.next=8;return loadLibrary('basis_transcoder.wasm','textures',options);case 8:_context27.t2=_context27.sent;_context27.t3=[_context27.t1,_context27.t2];_context27.next=12;return _context27.t0.all.call(_context27.t0,_context27.t3);case 12:_yield$Promise$all=_context27.sent;_yield$Promise$all2=_slicedToArray(_yield$Promise$all,2);BASIS=_yield$Promise$all2[0];wasmBinary=_yield$Promise$all2[1];BASIS=BASIS||globalThis.BASIS;_context27.next=19;return initializeBasisTrascoderModule(BASIS,wasmBinary);case 19:return _context27.abrupt("return",_context27.sent);case 20:case"end":return _context27.stop();}}},_callee23);}));return _loadBasisTrascoder.apply(this,arguments);}function initializeBasisTrascoderModule(BasisModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){BasisModule(options).then(function(module){var BasisFile=module.BasisFile,initializeBasis=module.initializeBasis;initializeBasis();resolve({BasisFile:BasisFile});});});}var loadBasisEncoderPromise;function loadBasisEncoderModule(_x41){return _loadBasisEncoderModule.apply(this,arguments);}function _loadBasisEncoderModule(){_loadBasisEncoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(options){var modules;return _regeneratorRuntime().wrap(function _callee24$(_context28){while(1){switch(_context28.prev=_context28.next){case 0:modules=options.modules||{};if(!modules.basisEncoder){_context28.next=3;break;}return _context28.abrupt("return",modules.basisEncoder);case 3:loadBasisEncoderPromise=loadBasisEncoderPromise||loadBasisEncoder(options);_context28.next=6;return loadBasisEncoderPromise;case 6:return _context28.abrupt("return",_context28.sent);case 7:case"end":return _context28.stop();}}},_callee24);}));return _loadBasisEncoderModule.apply(this,arguments);}function loadBasisEncoder(_x42){return _loadBasisEncoder.apply(this,arguments);}function _loadBasisEncoder(){_loadBasisEncoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(options){var BASIS_ENCODER,wasmBinary,_yield$Promise$all3,_yield$Promise$all4;return _regeneratorRuntime().wrap(function _callee25$(_context29){while(1){switch(_context29.prev=_context29.next){case 0:BASIS_ENCODER=null;wasmBinary=null;_context29.t0=Promise;_context29.next=5;return loadLibrary(BASIS_CDN_ENCODER_JS,'textures',options);case 5:_context29.t1=_context29.sent;_context29.next=8;return loadLibrary(BASIS_CDN_ENCODER_WASM,'textures',options);case 8:_context29.t2=_context29.sent;_context29.t3=[_context29.t1,_context29.t2];_context29.next=12;return _context29.t0.all.call(_context29.t0,_context29.t3);case 12:_yield$Promise$all3=_context29.sent;_yield$Promise$all4=_slicedToArray(_yield$Promise$all3,2);BASIS_ENCODER=_yield$Promise$all4[0];wasmBinary=_yield$Promise$all4[1];BASIS_ENCODER=BASIS_ENCODER||globalThis.BASIS;_context29.next=19;return initializeBasisEncoderModule(BASIS_ENCODER,wasmBinary);case 19:return _context29.abrupt("return",_context29.sent);case 20:case"end":return _context29.stop();}}},_callee25);}));return _loadBasisEncoder.apply(this,arguments);}function initializeBasisEncoderModule(BasisEncoderModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){BasisEncoderModule(options).then(function(module){var BasisFile=module.BasisFile,KTX2File=module.KTX2File,initializeBasis=module.initializeBasis,BasisEncoder=module.BasisEncoder;initializeBasis();resolve({BasisFile:BasisFile,KTX2File:KTX2File,BasisEncoder:BasisEncoder});});});}var GL_EXTENSIONS_CONSTANTS={COMPRESSED_RGB_S3TC_DXT1_EXT:0x83f0,COMPRESSED_RGBA_S3TC_DXT1_EXT:0x83f1,COMPRESSED_RGBA_S3TC_DXT3_EXT:0x83f2,COMPRESSED_RGBA_S3TC_DXT5_EXT:0x83f3,COMPRESSED_R11_EAC:0x9270,COMPRESSED_SIGNED_R11_EAC:0x9271,COMPRESSED_RG11_EAC:0x9272,COMPRESSED_SIGNED_RG11_EAC:0x9273,COMPRESSED_RGB8_ETC2:0x9274,COMPRESSED_RGBA8_ETC2_EAC:0x9275,COMPRESSED_SRGB8_ETC2:0x9276,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:0x9277,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:0x9278,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:0x9279,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:0x8c00,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:0x8c02,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:0x8c01,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:0x8c03,COMPRESSED_RGB_ETC1_WEBGL:0x8d64,COMPRESSED_RGB_ATC_WEBGL:0x8c92,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:0x8c93,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:0x87ee,COMPRESSED_RGBA_ASTC_4X4_KHR:0x93b0,COMPRESSED_RGBA_ASTC_5X4_KHR:0x93b1,COMPRESSED_RGBA_ASTC_5X5_KHR:0x93b2,COMPRESSED_RGBA_ASTC_6X5_KHR:0x93b3,COMPRESSED_RGBA_ASTC_6X6_KHR:0x93b4,COMPRESSED_RGBA_ASTC_8X5_KHR:0x93b5,COMPRESSED_RGBA_ASTC_8X6_KHR:0x93b6,COMPRESSED_RGBA_ASTC_8X8_KHR:0x93b7,COMPRESSED_RGBA_ASTC_10X5_KHR:0x93b8,COMPRESSED_RGBA_ASTC_10X6_KHR:0x93b9,COMPRESSED_RGBA_ASTC_10X8_KHR:0x93ba,COMPRESSED_RGBA_ASTC_10X10_KHR:0x93bb,COMPRESSED_RGBA_ASTC_12X10_KHR:0x93bc,COMPRESSED_RGBA_ASTC_12X12_KHR:0x93bd,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:0x93d0,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:0x93d1,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:0x93d2,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:0x93d3,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:0x93d4,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:0x93d5,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:0x93d6,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:0x93d7,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:0x93d8,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:0x93d9,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:0x93da,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:0x93db,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:0x93dc,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:0x93dd,COMPRESSED_RED_RGTC1_EXT:0x8dbb,COMPRESSED_SIGNED_RED_RGTC1_EXT:0x8dbc,COMPRESSED_RED_GREEN_RGTC2_EXT:0x8dbd,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:0x8dbe,COMPRESSED_SRGB_S3TC_DXT1_EXT:0x8c4c,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:0x8c4d,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:0x8c4e,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:0x8c4f};var BROWSER_PREFIXES=['','WEBKIT_','MOZ_'];var WEBGL_EXTENSIONS={WEBGL_compressed_texture_s3tc:'dxt',WEBGL_compressed_texture_s3tc_srgb:'dxt-srgb',WEBGL_compressed_texture_etc1:'etc1',WEBGL_compressed_texture_etc:'etc2',WEBGL_compressed_texture_pvrtc:'pvrtc',WEBGL_compressed_texture_atc:'atc',WEBGL_compressed_texture_astc:'astc',EXT_texture_compression_rgtc:'rgtc'};var formats=null;function getSupportedGPUTextureFormats(gl){if(!formats){gl=gl||getWebGLContext()||undefined;formats=new Set();var _iterator17=_createForOfIteratorHelper(BROWSER_PREFIXES),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var prefix=_step17.value;for(var extension in WEBGL_EXTENSIONS){if(gl&&gl.getExtension("".concat(prefix).concat(extension))){var gpuTextureFormat=WEBGL_EXTENSIONS[extension];formats.add(gpuTextureFormat);}}}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}}return formats;}function getWebGLContext(){try{var _canvas6=document.createElement('canvas');return _canvas6.getContext('webgl');}catch(error){return null;}}var n,i,s,a,r,o,l,f;!function(t){t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB";}(n||(n={})),function(t){t[t.BASICFORMAT=0]="BASICFORMAT";}(i||(i={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC";}(s||(s={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB";}(a||(a={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2";}(r||(r={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED";}(o||(o={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA";}(l||(l={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG";}(f||(f={}));var KTX2_ID=[0xab,0x4b,0x54,0x58,0x20,0x32,0x30,0xbb,0x0d,0x0a,0x1a,0x0a];function isKTX(data){var id=new Uint8Array(data);var notKTX=id.byteLength<KTX2_ID.length||id[0]!==KTX2_ID[0]||id[1]!==KTX2_ID[1]||id[2]!==KTX2_ID[2]||id[3]!==KTX2_ID[3]||id[4]!==KTX2_ID[4]||id[5]!==KTX2_ID[5]||id[6]!==KTX2_ID[6]||id[7]!==KTX2_ID[7]||id[8]!==KTX2_ID[8]||id[9]!==KTX2_ID[9]||id[10]!==KTX2_ID[10]||id[11]!==KTX2_ID[11];return!notKTX;}var OutputFormat={etc1:{basisFormat:0,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:true},bc1:{basisFormat:2,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:true},bc5:{basisFormat:5,compressed:true},'bc7-m6-opaque-only':{basisFormat:6,compressed:true},'bc7-m5':{basisFormat:7,compressed:true},'pvrtc1-4-rgb':{basisFormat:8,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},'pvrtc1-4-rgba':{basisFormat:9,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},'astc-4x4':{basisFormat:10,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR},'atc-rgb':{basisFormat:11,compressed:true},'atc-rgba-interpolated-alpha':{basisFormat:12,compressed:true},rgba32:{basisFormat:13,compressed:false},rgb565:{basisFormat:14,compressed:false},bgr565:{basisFormat:15,compressed:false},rgba4444:{basisFormat:16,compressed:false}};function parseBasis(_x43,_x44){return _parseBasis.apply(this,arguments);}function _parseBasis(){_parseBasis=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data,options){var fileConstructors,_yield$loadBasisTrasc,BasisFile,_fileConstructors,_yield$loadBasisTrasc2,_BasisFile;return _regeneratorRuntime().wrap(function _callee26$(_context30){while(1){switch(_context30.prev=_context30.next){case 0:if(!(options.basis.containerFormat==='auto')){_context30.next=11;break;}if(!isKTX(data)){_context30.next=6;break;}_context30.next=4;return loadBasisEncoderModule(options);case 4:fileConstructors=_context30.sent;return _context30.abrupt("return",parseKTX2File(fileConstructors.KTX2File,data,options));case 6:_context30.next=8;return loadBasisTrascoderModule(options);case 8:_yield$loadBasisTrasc=_context30.sent;BasisFile=_yield$loadBasisTrasc.BasisFile;return _context30.abrupt("return",parseBasisFile(BasisFile,data,options));case 11:_context30.t0=options.basis.module;_context30.next=_context30.t0==='encoder'?14:_context30.t0==='transcoder'?22:22;break;case 14:_context30.next=16;return loadBasisEncoderModule(options);case 16:_fileConstructors=_context30.sent;_context30.t1=options.basis.containerFormat;_context30.next=_context30.t1==='ktx2'?20:_context30.t1==='basis'?21:21;break;case 20:return _context30.abrupt("return",parseKTX2File(_fileConstructors.KTX2File,data,options));case 21:return _context30.abrupt("return",parseBasisFile(_fileConstructors.BasisFile,data,options));case 22:_context30.next=24;return loadBasisTrascoderModule(options);case 24:_yield$loadBasisTrasc2=_context30.sent;_BasisFile=_yield$loadBasisTrasc2.BasisFile;return _context30.abrupt("return",parseBasisFile(_BasisFile,data,options));case 27:case"end":return _context30.stop();}}},_callee26);}));return _parseBasis.apply(this,arguments);}function parseBasisFile(BasisFile,data,options){var basisFile=new BasisFile(new Uint8Array(data));try{if(!basisFile.startTranscoding()){throw new Error('Failed to start basis transcoding');}var imageCount=basisFile.getNumImages();var images=[];for(var imageIndex=0;imageIndex<imageCount;imageIndex++){var levelsCount=basisFile.getNumLevels(imageIndex);var levels=[];for(var levelIndex=0;levelIndex<levelsCount;levelIndex++){levels.push(transcodeImage(basisFile,imageIndex,levelIndex,options));}images.push(levels);}return images;}finally{basisFile.close();basisFile["delete"]();}}function transcodeImage(basisFile,imageIndex,levelIndex,options){var width=basisFile.getImageWidth(imageIndex,levelIndex);var height=basisFile.getImageHeight(imageIndex,levelIndex);var hasAlpha=basisFile.getHasAlpha();var _getBasisOptions=getBasisOptions(options,hasAlpha),compressed=_getBasisOptions.compressed,format=_getBasisOptions.format,basisFormat=_getBasisOptions.basisFormat;var decodedSize=basisFile.getImageTranscodedSizeInBytes(imageIndex,levelIndex,basisFormat);var decodedData=new Uint8Array(decodedSize);if(!basisFile.transcodeImage(decodedData,imageIndex,levelIndex,basisFormat,0,0)){throw new Error('failed to start Basis transcoding');}return{width:width,height:height,data:decodedData,compressed:compressed,format:format,hasAlpha:hasAlpha};}function parseKTX2File(KTX2File,data,options){var ktx2File=new KTX2File(new Uint8Array(data));try{if(!ktx2File.startTranscoding()){throw new Error('failed to start KTX2 transcoding');}var levelsCount=ktx2File.getLevels();var levels=[];for(var levelIndex=0;levelIndex<levelsCount;levelIndex++){levels.push(transcodeKTX2Image(ktx2File,levelIndex,options));break;}return[levels];}finally{ktx2File.close();ktx2File["delete"]();}}function transcodeKTX2Image(ktx2File,levelIndex,options){var _ktx2File$getImageLev=ktx2File.getImageLevelInfo(levelIndex,0,0),alphaFlag=_ktx2File$getImageLev.alphaFlag,height=_ktx2File$getImageLev.height,width=_ktx2File$getImageLev.width;var _getBasisOptions2=getBasisOptions(options,alphaFlag),compressed=_getBasisOptions2.compressed,format=_getBasisOptions2.format,basisFormat=_getBasisOptions2.basisFormat;var decodedSize=ktx2File.getImageTranscodedSizeInBytes(levelIndex,0,0,basisFormat);var decodedData=new Uint8Array(decodedSize);if(!ktx2File.transcodeImage(decodedData,levelIndex,0,0,basisFormat,0,-1,-1)){throw new Error('Failed to transcode KTX2 image');}return{width:width,height:height,data:decodedData,compressed:compressed,hasAlpha:alphaFlag,format:format};}function getBasisOptions(options,hasAlpha){var format=options&&options.basis&&options.basis.format;if(format==='auto'){format=selectSupportedBasisFormat();}if(_typeof(format)==='object'){format=hasAlpha?format.alpha:format.noAlpha;}format=format.toLowerCase();return OutputFormat[format];}function selectSupportedBasisFormat(){var supportedFormats=getSupportedGPUTextureFormats();if(supportedFormats.has('astc')){return'astc-4x4';}else if(supportedFormats.has('dxt')){return{alpha:'bc3',noAlpha:'bc1'};}else if(supportedFormats.has('pvrtc')){return{alpha:'pvrtc1-4-rgba',noAlpha:'pvrtc1-4-rgb'};}else if(supportedFormats.has('etc1')){return'etc1';}else if(supportedFormats.has('etc2')){return'etc2';}return'rgb565';}var BasisWorkerLoader={name:'Basis',id:'basis',module:'textures',version:VERSION$4,worker:true,extensions:['basis','ktx2'],mimeTypes:['application/octet-stream','image/ktx2'],tests:['sB'],binary:true,options:{basis:{format:'auto',libraryPath:'libs/',containerFormat:'auto',module:'transcoder'}}};var BasisLoader=_objectSpread(_objectSpread({},BasisWorkerLoader),{},{parse:parseBasis});var VERSION$2="3.2.6";var _parseImageNode=globalThis._parseImageNode;var IMAGE_SUPPORTED=typeof Image!=='undefined';var IMAGE_BITMAP_SUPPORTED=typeof ImageBitmap!=='undefined';var NODE_IMAGE_SUPPORTED=Boolean(_parseImageNode);var DATA_SUPPORTED=isBrowser$4?true:NODE_IMAGE_SUPPORTED;function isImageTypeSupported(type){switch(type){case'auto':return IMAGE_BITMAP_SUPPORTED||IMAGE_SUPPORTED||DATA_SUPPORTED;case'imagebitmap':return IMAGE_BITMAP_SUPPORTED;case'image':return IMAGE_SUPPORTED;case'data':return DATA_SUPPORTED;default:throw new Error("@loaders.gl/images: image ".concat(type," not supported in this environment"));}}function getDefaultImageType(){if(IMAGE_BITMAP_SUPPORTED){return'imagebitmap';}if(IMAGE_SUPPORTED){return'image';}if(DATA_SUPPORTED){return'data';}throw new Error('Install \'@loaders.gl/polyfills\' to parse images under Node.js');}function getImageType(image){var format=getImageTypeOrNull(image);if(!format){throw new Error('Not an image');}return format;}function getImageData(image){switch(getImageType(image)){case'data':return image;case'image':case'imagebitmap':var _canvas7=document.createElement('canvas');var context=_canvas7.getContext('2d');if(!context){throw new Error('getImageData');}_canvas7.width=image.width;_canvas7.height=image.height;context.drawImage(image,0,0);return context.getImageData(0,0,image.width,image.height);default:throw new Error('getImageData');}}function getImageTypeOrNull(image){if(typeof ImageBitmap!=='undefined'&&image instanceof ImageBitmap){return'imagebitmap';}if(typeof Image!=='undefined'&&image instanceof Image){return'image';}if(image&&_typeof(image)==='object'&&image.data&&image.width&&image.height){return'data';}return null;}var SVG_DATA_URL_PATTERN=/^data:image\/svg\+xml/;var SVG_URL_PATTERN=/\.svg((\?|#).*)?$/;function isSVG(url){return url&&(SVG_DATA_URL_PATTERN.test(url)||SVG_URL_PATTERN.test(url));}function getBlobOrSVGDataUrl(arrayBuffer,url){if(isSVG(url)){var textDecoder=new TextDecoder();var xmlText=textDecoder.decode(arrayBuffer);try{if(typeof unescape==='function'&&typeof encodeURIComponent==='function'){xmlText=unescape(encodeURIComponent(xmlText));}}catch(error){throw new Error(error.message);}var src="data:image/svg+xml;base64,".concat(btoa(xmlText));return src;}return getBlob(arrayBuffer,url);}function getBlob(arrayBuffer,url){if(isSVG(url)){throw new Error('SVG cannot be parsed directly to imagebitmap');}return new Blob([new Uint8Array(arrayBuffer)]);}function parseToImage(_x45,_x46,_x47){return _parseToImage.apply(this,arguments);}function _parseToImage(){_parseToImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(arrayBuffer,options,url){var blobOrDataUrl,URL,objectUrl;return _regeneratorRuntime().wrap(function _callee27$(_context31){while(1){switch(_context31.prev=_context31.next){case 0:blobOrDataUrl=getBlobOrSVGDataUrl(arrayBuffer,url);URL=self.URL||self.webkitURL;objectUrl=typeof blobOrDataUrl!=='string'&&URL.createObjectURL(blobOrDataUrl);_context31.prev=3;_context31.next=6;return loadToImage(objectUrl||blobOrDataUrl,options);case 6:return _context31.abrupt("return",_context31.sent);case 7:_context31.prev=7;if(objectUrl){URL.revokeObjectURL(objectUrl);}return _context31.finish(7);case 10:case"end":return _context31.stop();}}},_callee27,null,[[3,,7,10]]);}));return _parseToImage.apply(this,arguments);}function loadToImage(_x48,_x49){return _loadToImage.apply(this,arguments);}function _loadToImage(){_loadToImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(url,options){var image;return _regeneratorRuntime().wrap(function _callee28$(_context32){while(1){switch(_context32.prev=_context32.next){case 0:image=new Image();image.src=url;if(!(options.image&&options.image.decode&&image.decode)){_context32.next=6;break;}_context32.next=5;return image.decode();case 5:return _context32.abrupt("return",image);case 6:_context32.next=8;return new Promise(function(resolve,reject){try{image.onload=function(){return resolve(image);};image.onerror=function(err){return reject(new Error("Could not load image ".concat(url,": ").concat(err)));};}catch(error){reject(error);}});case 8:return _context32.abrupt("return",_context32.sent);case 9:case"end":return _context32.stop();}}},_callee28);}));return _loadToImage.apply(this,arguments);}var EMPTY_OBJECT={};var imagebitmapOptionsSupported=true;function parseToImageBitmap(_x50,_x51,_x52){return _parseToImageBitmap.apply(this,arguments);}function _parseToImageBitmap(){_parseToImageBitmap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(arrayBuffer,options,url){var blob,_image8,imagebitmapOptions;return _regeneratorRuntime().wrap(function _callee29$(_context33){while(1){switch(_context33.prev=_context33.next){case 0:if(!isSVG(url)){_context33.next=7;break;}_context33.next=3;return parseToImage(arrayBuffer,options,url);case 3:_image8=_context33.sent;blob=_image8;_context33.next=8;break;case 7:blob=getBlob(arrayBuffer,url);case 8:imagebitmapOptions=options&&options.imagebitmap;_context33.next=11;return safeCreateImageBitmap(blob,imagebitmapOptions);case 11:return _context33.abrupt("return",_context33.sent);case 12:case"end":return _context33.stop();}}},_callee29);}));return _parseToImageBitmap.apply(this,arguments);}function safeCreateImageBitmap(_x53){return _safeCreateImageBitmap.apply(this,arguments);}function _safeCreateImageBitmap(){_safeCreateImageBitmap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(blob){var imagebitmapOptions,_args28=arguments;return _regeneratorRuntime().wrap(function _callee30$(_context34){while(1){switch(_context34.prev=_context34.next){case 0:imagebitmapOptions=_args28.length>1&&_args28[1]!==undefined?_args28[1]:null;if(isEmptyObject(imagebitmapOptions)||!imagebitmapOptionsSupported){imagebitmapOptions=null;}if(!imagebitmapOptions){_context34.next=13;break;}_context34.prev=3;_context34.next=6;return createImageBitmap(blob,imagebitmapOptions);case 6:return _context34.abrupt("return",_context34.sent);case 9:_context34.prev=9;_context34.t0=_context34["catch"](3);console.warn(_context34.t0);imagebitmapOptionsSupported=false;case 13:_context34.next=15;return createImageBitmap(blob);case 15:return _context34.abrupt("return",_context34.sent);case 16:case"end":return _context34.stop();}}},_callee30,null,[[3,9]]);}));return _safeCreateImageBitmap.apply(this,arguments);}function isEmptyObject(object){for(var key in object||EMPTY_OBJECT){return false;}return true;}var BIG_ENDIAN=false;var LITTLE_ENDIAN=true;function getBinaryImageMetadata(binaryData){var dataView=toDataView(binaryData);return getPngMetadata(dataView)||getJpegMetadata(dataView)||getGifMetadata(dataView)||getBmpMetadata(dataView);}function getPngMetadata(binaryData){var dataView=toDataView(binaryData);var isPng=dataView.byteLength>=24&&dataView.getUint32(0,BIG_ENDIAN)===0x89504e47;if(!isPng){return null;}return{mimeType:'image/png',width:dataView.getUint32(16,BIG_ENDIAN),height:dataView.getUint32(20,BIG_ENDIAN)};}function getGifMetadata(binaryData){var dataView=toDataView(binaryData);var isGif=dataView.byteLength>=10&&dataView.getUint32(0,BIG_ENDIAN)===0x47494638;if(!isGif){return null;}return{mimeType:'image/gif',width:dataView.getUint16(6,LITTLE_ENDIAN),height:dataView.getUint16(8,LITTLE_ENDIAN)};}function getBmpMetadata(binaryData){var dataView=toDataView(binaryData);var isBmp=dataView.byteLength>=14&&dataView.getUint16(0,BIG_ENDIAN)===0x424d&&dataView.getUint32(2,LITTLE_ENDIAN)===dataView.byteLength;if(!isBmp){return null;}return{mimeType:'image/bmp',width:dataView.getUint32(18,LITTLE_ENDIAN),height:dataView.getUint32(22,LITTLE_ENDIAN)};}function getJpegMetadata(binaryData){var dataView=toDataView(binaryData);var isJpeg=dataView.byteLength>=3&&dataView.getUint16(0,BIG_ENDIAN)===0xffd8&&dataView.getUint8(2)===0xff;if(!isJpeg){return null;}var _getJpegMarkers=getJpegMarkers(),tableMarkers=_getJpegMarkers.tableMarkers,sofMarkers=_getJpegMarkers.sofMarkers;var i=2;while(i+9<dataView.byteLength){var marker=dataView.getUint16(i,BIG_ENDIAN);if(sofMarkers.has(marker)){return{mimeType:'image/jpeg',height:dataView.getUint16(i+5,BIG_ENDIAN),width:dataView.getUint16(i+7,BIG_ENDIAN)};}if(!tableMarkers.has(marker)){return null;}i+=2;i+=dataView.getUint16(i,BIG_ENDIAN);}return null;}function getJpegMarkers(){var tableMarkers=new Set([0xffdb,0xffc4,0xffcc,0xffdd,0xfffe]);for(var _i514=0xffe0;_i514<0xfff0;++_i514){tableMarkers.add(_i514);}var sofMarkers=new Set([0xffc0,0xffc1,0xffc2,0xffc3,0xffc5,0xffc6,0xffc7,0xffc9,0xffca,0xffcb,0xffcd,0xffce,0xffcf,0xffde]);return{tableMarkers:tableMarkers,sofMarkers:sofMarkers};}function toDataView(data){if(data instanceof DataView){return data;}if(ArrayBuffer.isView(data)){return new DataView(data.buffer);}if(data instanceof ArrayBuffer){return new DataView(data);}throw new Error('toDataView');}function parseToNodeImage(_x54,_x55){return _parseToNodeImage.apply(this,arguments);}function _parseToNodeImage(){_parseToNodeImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(arrayBuffer,options){var _ref27,mimeType,_parseImageNode;return _regeneratorRuntime().wrap(function _callee31$(_context35){while(1){switch(_context35.prev=_context35.next){case 0:_ref27=getBinaryImageMetadata(arrayBuffer)||{},mimeType=_ref27.mimeType;_parseImageNode=globalThis._parseImageNode;assert$5(_parseImageNode);_context35.next=5;return _parseImageNode(arrayBuffer,mimeType);case 5:return _context35.abrupt("return",_context35.sent);case 6:case"end":return _context35.stop();}}},_callee31);}));return _parseToNodeImage.apply(this,arguments);}function parseImage(_x56,_x57,_x58){return _parseImage.apply(this,arguments);}function _parseImage(){_parseImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(arrayBuffer,options,context){var imageOptions,imageType,_ref28,url,loadType,image;return _regeneratorRuntime().wrap(function _callee32$(_context36){while(1){switch(_context36.prev=_context36.next){case 0:options=options||{};imageOptions=options.image||{};imageType=imageOptions.type||'auto';_ref28=context||{},url=_ref28.url;loadType=getLoadableImageType(imageType);_context36.t0=loadType;_context36.next=_context36.t0==='imagebitmap'?8:_context36.t0==='image'?12:_context36.t0==='data'?16:20;break;case 8:_context36.next=10;return parseToImageBitmap(arrayBuffer,options,url);case 10:image=_context36.sent;return _context36.abrupt("break",21);case 12:_context36.next=14;return parseToImage(arrayBuffer,options,url);case 14:image=_context36.sent;return _context36.abrupt("break",21);case 16:_context36.next=18;return parseToNodeImage(arrayBuffer);case 18:image=_context36.sent;return _context36.abrupt("break",21);case 20:assert$5(false);case 21:if(imageType==='data'){image=getImageData(image);}return _context36.abrupt("return",image);case 23:case"end":return _context36.stop();}}},_callee32);}));return _parseImage.apply(this,arguments);}function getLoadableImageType(type){switch(type){case'auto':case'data':return getDefaultImageType();default:isImageTypeSupported(type);return type;}}var EXTENSIONS$1=['png','jpg','jpeg','gif','webp','bmp','ico','svg'];var MIME_TYPES=['image/png','image/jpeg','image/gif','image/webp','image/bmp','image/vnd.microsoft.icon','image/svg+xml'];var DEFAULT_IMAGE_LOADER_OPTIONS={image:{type:'auto',decode:true}};var ImageLoader={id:'image',module:'images',name:'Images',version:VERSION$2,mimeTypes:MIME_TYPES,extensions:EXTENSIONS$1,parse:parseImage,tests:[function(arrayBuffer){return Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)));}],options:DEFAULT_IMAGE_LOADER_OPTIONS};var NODE_FORMAT_SUPPORT=['image/png','image/jpeg','image/gif'];var mimeTypeSupported={};function _isImageFormatSupported(mimeType){if(mimeTypeSupported[mimeType]===undefined){mimeTypeSupported[mimeType]=checkFormatSupport(mimeType);}return mimeTypeSupported[mimeType];}function checkFormatSupport(mimeType){switch(mimeType){case'image/webp':return checkWebPSupport();case'image/svg':return isBrowser$4;default:if(!isBrowser$4){var _parseImageNode2=globalThis._parseImageNode;return Boolean(_parseImageNode2)&&NODE_FORMAT_SUPPORT.includes(mimeType);}return true;}}function checkWebPSupport(){if(!isBrowser$4){return false;}try{var element=document.createElement('canvas');return element.toDataURL('image/webp').indexOf('data:image/webp')===0;}catch(_unused){return false;}}function assert$1(condition,message){if(!condition){throw new Error(message||'assert failed: gltf');}}function resolveUrl(url,options){var absolute=url.startsWith('data:')||url.startsWith('http:')||url.startsWith('https:');if(absolute){return url;}var baseUrl=options.baseUri||options.uri;if(!baseUrl){throw new Error("'baseUri' must be provided to resolve relative url ".concat(url));}return baseUrl.substr(0,baseUrl.lastIndexOf('/')+1)+url;}function getTypedArrayForBufferView(json,buffers,bufferViewIndex){var bufferView=json.bufferViews[bufferViewIndex];assert$1(bufferView);var bufferIndex=bufferView.buffer;var binChunk=buffers[bufferIndex];assert$1(binChunk);var byteOffset=(bufferView.byteOffset||0)+binChunk.byteOffset;return new Uint8Array(binChunk.arrayBuffer,byteOffset,bufferView.byteLength);}var TYPES=['SCALAR','VEC2','VEC3','VEC4'];var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]];var ARRAY_TO_COMPONENT_TYPE=new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);var ATTRIBUTE_TYPE_TO_COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function getAccessorTypeFromSize(size){var type=TYPES[size-1];return type||TYPES[0];}function getComponentTypeFromArray(typedArray){var componentType=ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);if(!componentType){throw new Error('Illegal typed array');}return componentType;}function getAccessorArrayTypeAndLength(accessor,bufferView){var ArrayType=ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];var components=ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];var bytesPerComponent=ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];var length=accessor.count*components;var byteLength=accessor.count*components*bytesPerComponent;assert$1(byteLength>=0&&byteLength<=bufferView.byteLength);return{ArrayType:ArrayType,length:length,byteLength:byteLength};}var DEFAULT_GLTF_JSON={asset:{version:'2.0',generator:'loaders.gl'},buffers:[]};var GLTFScenegraph=/*#__PURE__*/function(){function GLTFScenegraph(gltf){_classCallCheck(this,GLTFScenegraph);_defineProperty(this,"gltf",void 0);_defineProperty(this,"sourceBuffers",void 0);_defineProperty(this,"byteLength",void 0);this.gltf=gltf||{json:_objectSpread({},DEFAULT_GLTF_JSON),buffers:[]};this.sourceBuffers=[];this.byteLength=0;if(this.gltf.buffers&&this.gltf.buffers[0]){this.byteLength=this.gltf.buffers[0].byteLength;this.sourceBuffers=[this.gltf.buffers[0]];}}_createClass(GLTFScenegraph,[{key:"json",get:function get(){return this.gltf.json;}},{key:"getApplicationData",value:function getApplicationData(key){var data=this.json[key];return data;}},{key:"getExtraData",value:function getExtraData(key){var extras=this.json.extras||{};return extras[key];}},{key:"getExtension",value:function getExtension(extensionName){var isExtension=this.getUsedExtensions().find(function(name){return name===extensionName;});var extensions=this.json.extensions||{};return isExtension?extensions[extensionName]||true:null;}},{key:"getRequiredExtension",value:function getRequiredExtension(extensionName){var isRequired=this.getRequiredExtensions().find(function(name){return name===extensionName;});return isRequired?this.getExtension(extensionName):null;}},{key:"getRequiredExtensions",value:function getRequiredExtensions(){return this.json.extensionsRequired||[];}},{key:"getUsedExtensions",value:function getUsedExtensions(){return this.json.extensionsUsed||[];}},{key:"getObjectExtension",value:function getObjectExtension(object,extensionName){var extensions=object.extensions||{};return extensions[extensionName];}},{key:"getScene",value:function getScene(index){return this.getObject('scenes',index);}},{key:"getNode",value:function getNode(index){return this.getObject('nodes',index);}},{key:"getSkin",value:function getSkin(index){return this.getObject('skins',index);}},{key:"getMesh",value:function getMesh(index){return this.getObject('meshes',index);}},{key:"getMaterial",value:function getMaterial(index){return this.getObject('materials',index);}},{key:"getAccessor",value:function getAccessor(index){return this.getObject('accessors',index);}},{key:"getTexture",value:function getTexture(index){return this.getObject('textures',index);}},{key:"getSampler",value:function getSampler(index){return this.getObject('samplers',index);}},{key:"getImage",value:function getImage(index){return this.getObject('images',index);}},{key:"getBufferView",value:function getBufferView(index){return this.getObject('bufferViews',index);}},{key:"getBuffer",value:function getBuffer(index){return this.getObject('buffers',index);}},{key:"getObject",value:function getObject(array,index){if(_typeof(index)==='object'){return index;}var object=this.json[array]&&this.json[array][index];if(!object){throw new Error("glTF file error: Could not find ".concat(array,"[").concat(index,"]"));}return object;}},{key:"getTypedArrayForBufferView",value:function getTypedArrayForBufferView(bufferView){bufferView=this.getBufferView(bufferView);var bufferIndex=bufferView.buffer;var binChunk=this.gltf.buffers[bufferIndex];assert$1(binChunk);var byteOffset=(bufferView.byteOffset||0)+binChunk.byteOffset;return new Uint8Array(binChunk.arrayBuffer,byteOffset,bufferView.byteLength);}},{key:"getTypedArrayForAccessor",value:function getTypedArrayForAccessor(accessor){accessor=this.getAccessor(accessor);var bufferView=this.getBufferView(accessor.bufferView);var buffer=this.getBuffer(bufferView.buffer);var arrayBuffer=buffer.data;var _getAccessorArrayType=getAccessorArrayTypeAndLength(accessor,bufferView),ArrayType=_getAccessorArrayType.ArrayType,length=_getAccessorArrayType.length;var byteOffset=bufferView.byteOffset+accessor.byteOffset;return new ArrayType(arrayBuffer,byteOffset,length);}},{key:"getTypedArrayForImageData",value:function getTypedArrayForImageData(image){image=this.getAccessor(image);var bufferView=this.getBufferView(image.bufferView);var buffer=this.getBuffer(bufferView.buffer);var arrayBuffer=buffer.data;var byteOffset=bufferView.byteOffset||0;return new Uint8Array(arrayBuffer,byteOffset,bufferView.byteLength);}},{key:"addApplicationData",value:function addApplicationData(key,data){this.json[key]=data;return this;}},{key:"addExtraData",value:function addExtraData(key,data){this.json.extras=this.json.extras||{};this.json.extras[key]=data;return this;}},{key:"addObjectExtension",value:function addObjectExtension(object,extensionName,data){object.extensions=object.extensions||{};object.extensions[extensionName]=data;this.registerUsedExtension(extensionName);return this;}},{key:"setObjectExtension",value:function setObjectExtension(object,extensionName,data){var extensions=object.extensions||{};extensions[extensionName]=data;}},{key:"removeObjectExtension",value:function removeObjectExtension(object,extensionName){var extensions=object.extensions||{};var extension=extensions[extensionName];delete extensions[extensionName];return extension;}},{key:"addExtension",value:function addExtension(extensionName){var extensionData=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};assert$1(extensionData);this.json.extensions=this.json.extensions||{};this.json.extensions[extensionName]=extensionData;this.registerUsedExtension(extensionName);return extensionData;}},{key:"addRequiredExtension",value:function addRequiredExtension(extensionName){var extensionData=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};assert$1(extensionData);this.addExtension(extensionName,extensionData);this.registerRequiredExtension(extensionName);return extensionData;}},{key:"registerUsedExtension",value:function registerUsedExtension(extensionName){this.json.extensionsUsed=this.json.extensionsUsed||[];if(!this.json.extensionsUsed.find(function(ext){return ext===extensionName;})){this.json.extensionsUsed.push(extensionName);}}},{key:"registerRequiredExtension",value:function registerRequiredExtension(extensionName){this.registerUsedExtension(extensionName);this.json.extensionsRequired=this.json.extensionsRequired||[];if(!this.json.extensionsRequired.find(function(ext){return ext===extensionName;})){this.json.extensionsRequired.push(extensionName);}}},{key:"removeExtension",value:function removeExtension(extensionName){if(this.json.extensionsRequired){this._removeStringFromArray(this.json.extensionsRequired,extensionName);}if(this.json.extensionsUsed){this._removeStringFromArray(this.json.extensionsUsed,extensionName);}if(this.json.extensions){delete this.json.extensions[extensionName];}}},{key:"setDefaultScene",value:function setDefaultScene(sceneIndex){this.json.scene=sceneIndex;}},{key:"addScene",value:function addScene(scene){var nodeIndices=scene.nodeIndices;this.json.scenes=this.json.scenes||[];this.json.scenes.push({nodes:nodeIndices});return this.json.scenes.length-1;}},{key:"addNode",value:function addNode(node){var meshIndex=node.meshIndex,matrix=node.matrix;this.json.nodes=this.json.nodes||[];var nodeData={mesh:meshIndex};if(matrix){nodeData.matrix=matrix;}this.json.nodes.push(nodeData);return this.json.nodes.length-1;}},{key:"addMesh",value:function addMesh(mesh){var attributes=mesh.attributes,indices=mesh.indices,material=mesh.material,_mesh$mode=mesh.mode,mode=_mesh$mode===void 0?4:_mesh$mode;var accessors=this._addAttributes(attributes);var glTFMesh={primitives:[{attributes:accessors,mode:mode}]};if(indices){var indicesAccessor=this._addIndices(indices);glTFMesh.primitives[0].indices=indicesAccessor;}if(Number.isFinite(material)){glTFMesh.primitives[0].material=material;}this.json.meshes=this.json.meshes||[];this.json.meshes.push(glTFMesh);return this.json.meshes.length-1;}},{key:"addPointCloud",value:function addPointCloud(attributes){var accessorIndices=this._addAttributes(attributes);var glTFMesh={primitives:[{attributes:accessorIndices,mode:0}]};this.json.meshes=this.json.meshes||[];this.json.meshes.push(glTFMesh);return this.json.meshes.length-1;}},{key:"addImage",value:function addImage(imageData,mimeTypeOpt){var metadata=getBinaryImageMetadata(imageData);var mimeType=mimeTypeOpt||(metadata===null||metadata===void 0?void 0:metadata.mimeType);var bufferViewIndex=this.addBufferView(imageData);var glTFImage={bufferView:bufferViewIndex,mimeType:mimeType};this.json.images=this.json.images||[];this.json.images.push(glTFImage);return this.json.images.length-1;}},{key:"addBufferView",value:function addBufferView(buffer){var byteLength=buffer.byteLength;assert$1(Number.isFinite(byteLength));this.sourceBuffers=this.sourceBuffers||[];this.sourceBuffers.push(buffer);var glTFBufferView={buffer:0,byteOffset:this.byteLength,byteLength:byteLength};this.byteLength+=padToNBytes(byteLength,4);this.json.bufferViews=this.json.bufferViews||[];this.json.bufferViews.push(glTFBufferView);return this.json.bufferViews.length-1;}},{key:"addAccessor",value:function addAccessor(bufferViewIndex,accessor){var glTFAccessor={bufferView:bufferViewIndex,type:getAccessorTypeFromSize(accessor.size),componentType:accessor.componentType,count:accessor.count,max:accessor.max,min:accessor.min};this.json.accessors=this.json.accessors||[];this.json.accessors.push(glTFAccessor);return this.json.accessors.length-1;}},{key:"addBinaryBuffer",value:function addBinaryBuffer(sourceBuffer){var accessor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{size:3};var bufferViewIndex=this.addBufferView(sourceBuffer);var minMax={min:accessor.min,max:accessor.max};if(!minMax.min||!minMax.max){minMax=this._getAccessorMinMax(sourceBuffer,accessor.size);}var accessorDefaults={size:accessor.size,componentType:getComponentTypeFromArray(sourceBuffer),count:Math.round(sourceBuffer.length/accessor.size),min:minMax.min,max:minMax.max};return this.addAccessor(bufferViewIndex,Object.assign(accessorDefaults,accessor));}},{key:"addTexture",value:function addTexture(texture){var imageIndex=texture.imageIndex;var glTFTexture={source:imageIndex};this.json.textures=this.json.textures||[];this.json.textures.push(glTFTexture);return this.json.textures.length-1;}},{key:"addMaterial",value:function addMaterial(pbrMaterialInfo){this.json.materials=this.json.materials||[];this.json.materials.push(pbrMaterialInfo);return this.json.materials.length-1;}},{key:"createBinaryChunk",value:function createBinaryChunk(){var _this$json,_this$json$buffers;this.gltf.buffers=[];var totalByteLength=this.byteLength;var arrayBuffer=new ArrayBuffer(totalByteLength);var targetArray=new Uint8Array(arrayBuffer);var dstByteOffset=0;var _iterator18=_createForOfIteratorHelper(this.sourceBuffers||[]),_step18;try{for(_iterator18.s();!(_step18=_iterator18.n()).done;){var sourceBuffer=_step18.value;dstByteOffset=copyToArray(sourceBuffer,targetArray,dstByteOffset);}}catch(err){_iterator18.e(err);}finally{_iterator18.f();}if((_this$json=this.json)!==null&&_this$json!==void 0&&(_this$json$buffers=_this$json.buffers)!==null&&_this$json$buffers!==void 0&&_this$json$buffers[0]){this.json.buffers[0].byteLength=totalByteLength;}else{this.json.buffers=[{byteLength:totalByteLength}];}this.gltf.binary=arrayBuffer;this.sourceBuffers=[arrayBuffer];}},{key:"_removeStringFromArray",value:function _removeStringFromArray(array,string){var found=true;while(found){var index=array.indexOf(string);if(index>-1){array.splice(index,1);}else{found=false;}}}},{key:"_addAttributes",value:function _addAttributes(){var attributes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var result={};for(var attributeKey in attributes){var attributeData=attributes[attributeKey];var attrName=this._getGltfAttributeName(attributeKey);var accessor=this.addBinaryBuffer(attributeData.value,attributeData);result[attrName]=accessor;}return result;}},{key:"_addIndices",value:function _addIndices(indices){return this.addBinaryBuffer(indices,{size:1});}},{key:"_getGltfAttributeName",value:function _getGltfAttributeName(attributeName){switch(attributeName.toLowerCase()){case'position':case'positions':case'vertices':return'POSITION';case'normal':case'normals':return'NORMAL';case'color':case'colors':return'COLOR_0';case'texcoord':case'texcoords':return'TEXCOORD_0';default:return attributeName;}}},{key:"_getAccessorMinMax",value:function _getAccessorMinMax(buffer,size){var result={min:null,max:null};if(buffer.length<size){return result;}result.min=[];result.max=[];var initValues=buffer.subarray(0,size);var _iterator19=_createForOfIteratorHelper(initValues),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var value=_step19.value;result.min.push(value);result.max.push(value);}}catch(err){_iterator19.e(err);}finally{_iterator19.f();}for(var index=size;index<buffer.length;index+=size){for(var componentIndex=0;componentIndex<size;componentIndex++){result.min[0+componentIndex]=Math.min(result.min[0+componentIndex],buffer[index+componentIndex]);result.max[0+componentIndex]=Math.max(result.max[0+componentIndex],buffer[index+componentIndex]);}}return result;}}]);return GLTFScenegraph;}();var wasm_base='B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB';var wasm_simd='B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB';var detector=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);var wasmpack=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);var FILTERS={0:'',1:'meshopt_decodeFilterOct',2:'meshopt_decodeFilterQuat',3:'meshopt_decodeFilterExp',NONE:'',OCTAHEDRAL:'meshopt_decodeFilterOct',QUATERNION:'meshopt_decodeFilterQuat',EXPONENTIAL:'meshopt_decodeFilterExp'};var DECODERS={0:'meshopt_decodeVertexBuffer',1:'meshopt_decodeIndexBuffer',2:'meshopt_decodeIndexSequence',ATTRIBUTES:'meshopt_decodeVertexBuffer',TRIANGLES:'meshopt_decodeIndexBuffer',INDICES:'meshopt_decodeIndexSequence'};function meshoptDecodeGltfBuffer(_x59,_x60,_x61,_x62,_x63){return _meshoptDecodeGltfBuffer.apply(this,arguments);}function _meshoptDecodeGltfBuffer(){_meshoptDecodeGltfBuffer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(target,count,size,source,mode){var filter,instance,_args31=arguments;return _regeneratorRuntime().wrap(function _callee33$(_context37){while(1){switch(_context37.prev=_context37.next){case 0:filter=_args31.length>5&&_args31[5]!==undefined?_args31[5]:'NONE';_context37.next=3;return loadWasmInstance();case 3:instance=_context37.sent;decode$5(instance,instance.exports[DECODERS[mode]],target,count,size,source,instance.exports[FILTERS[filter||'NONE']]);case 5:case"end":return _context37.stop();}}},_callee33);}));return _meshoptDecodeGltfBuffer.apply(this,arguments);}var wasmPromise;function loadWasmInstance(){return _loadWasmInstance.apply(this,arguments);}function _loadWasmInstance(){_loadWasmInstance=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(){return _regeneratorRuntime().wrap(function _callee34$(_context38){while(1){switch(_context38.prev=_context38.next){case 0:if(!wasmPromise){wasmPromise=loadWasmModule();}return _context38.abrupt("return",wasmPromise);case 2:case"end":return _context38.stop();}}},_callee34);}));return _loadWasmInstance.apply(this,arguments);}function loadWasmModule(){return _loadWasmModule.apply(this,arguments);}function _loadWasmModule(){_loadWasmModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(){var wasm,result;return _regeneratorRuntime().wrap(function _callee35$(_context39){while(1){switch(_context39.prev=_context39.next){case 0:wasm=wasm_base;if(WebAssembly.validate(detector)){wasm=wasm_simd;console.log('Warning: meshopt_decoder is using experimental SIMD support');}_context39.next=4;return WebAssembly.instantiate(unpack(wasm),{});case 4:result=_context39.sent;_context39.next=7;return result.instance.exports.__wasm_call_ctors();case 7:return _context39.abrupt("return",result.instance);case 8:case"end":return _context39.stop();}}},_callee35);}));return _loadWasmModule.apply(this,arguments);}function unpack(data){var result=new Uint8Array(data.length);for(var _i515=0;_i515<data.length;++_i515){var ch=data.charCodeAt(_i515);result[_i515]=ch>96?ch-71:ch>64?ch-65:ch>47?ch+4:ch>46?63:62;}var write=0;for(var _i516=0;_i516<data.length;++_i516){result[write++]=result[_i516]<60?wasmpack[result[_i516]]:(result[_i516]-60)*64+result[++_i516];}return result.buffer.slice(0,write);}function decode$5(instance,fun,target,count,size,source,filter){var sbrk=instance.exports.sbrk;var count4=count+3&~3;var tp=sbrk(count4*size);var sp=sbrk(source.length);var heap=new Uint8Array(instance.exports.memory.buffer);heap.set(source,sp);var res=fun(tp,count,size,sp,source.length);if(res===0&&filter){filter(tp,count4,size);}target.set(heap.subarray(tp,tp+count*size));sbrk(tp-sbrk(0));if(res!==0){throw new Error("Malformed buffer data: ".concat(res));}}var EXT_MESHOPT_COMPRESSION='EXT_meshopt_compression';var name$6=EXT_MESHOPT_COMPRESSION;function decode$4(_x64,_x65){return _decode$.apply(this,arguments);}function _decode$(){_decode$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(gltfData,options){var _options$gltf,scenegraph,promises,_iterator49,_step49,bufferViewIndex;return _regeneratorRuntime().wrap(function _callee36$(_context40){while(1){switch(_context40.prev=_context40.next){case 0:scenegraph=new GLTFScenegraph(gltfData);if(options!==null&&options!==void 0&&(_options$gltf=options.gltf)!==null&&_options$gltf!==void 0&&_options$gltf.decompressMeshes){_context40.next=3;break;}return _context40.abrupt("return");case 3:promises=[];_iterator49=_createForOfIteratorHelper(gltfData.json.bufferViews||[]);try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){bufferViewIndex=_step49.value;promises.push(decodeMeshoptBufferView(scenegraph,bufferViewIndex));}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}_context40.next=8;return Promise.all(promises);case 8:scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);case 9:case"end":return _context40.stop();}}},_callee36);}));return _decode$.apply(this,arguments);}function decodeMeshoptBufferView(_x66,_x67){return _decodeMeshoptBufferView.apply(this,arguments);}function _decodeMeshoptBufferView(){_decodeMeshoptBufferView=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(scenegraph,bufferView){var meshoptExtension,_meshoptExtension$byt,byteOffset,_meshoptExtension$byt2,byteLength,byteStride,count,mode,_meshoptExtension$fil,filter,bufferIndex,buffer,source,result;return _regeneratorRuntime().wrap(function _callee37$(_context41){while(1){switch(_context41.prev=_context41.next){case 0:meshoptExtension=scenegraph.getObjectExtension(bufferView,EXT_MESHOPT_COMPRESSION);if(!meshoptExtension){_context41.next=9;break;}_meshoptExtension$byt=meshoptExtension.byteOffset,byteOffset=_meshoptExtension$byt===void 0?0:_meshoptExtension$byt,_meshoptExtension$byt2=meshoptExtension.byteLength,byteLength=_meshoptExtension$byt2===void 0?0:_meshoptExtension$byt2,byteStride=meshoptExtension.byteStride,count=meshoptExtension.count,mode=meshoptExtension.mode,_meshoptExtension$fil=meshoptExtension.filter,filter=_meshoptExtension$fil===void 0?'NONE':_meshoptExtension$fil,bufferIndex=meshoptExtension.buffer;buffer=scenegraph.gltf.buffers[bufferIndex];source=new Uint8Array(buffer.arrayBuffer,buffer.byteOffset+byteOffset,byteLength);result=new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,bufferView.byteOffset,bufferView.byteLength);_context41.next=8;return meshoptDecodeGltfBuffer(result,count,byteStride,source,mode,filter);case 8:return _context41.abrupt("return",result);case 9:return _context41.abrupt("return",null);case 10:case"end":return _context41.stop();}}},_callee37);}));return _decodeMeshoptBufferView.apply(this,arguments);}var EXT_meshopt_compression=/*#__PURE__*/Object.freeze({__proto__:null,name:name$6,decode:decode$4});var EXT_TEXTURE_WEBP='EXT_texture_webp';var name$5=EXT_TEXTURE_WEBP;function preprocess$3(gltfData,options){var scenegraph=new GLTFScenegraph(gltfData);if(!_isImageFormatSupported('image/webp')){if(scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)){throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP," not supported by browser"));}return;}var json=scenegraph.json;var _iterator20=_createForOfIteratorHelper(json.textures||[]),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var texture=_step20.value;var extension=scenegraph.getObjectExtension(texture,EXT_TEXTURE_WEBP);if(extension){texture.source=extension.source;}scenegraph.removeObjectExtension(texture,EXT_TEXTURE_WEBP);}}catch(err){_iterator20.e(err);}finally{_iterator20.f();}scenegraph.removeExtension(EXT_TEXTURE_WEBP);}var EXT_texture_webp=/*#__PURE__*/Object.freeze({__proto__:null,name:name$5,preprocess:preprocess$3});var KHR_TEXTURE_BASISU='KHR_texture_basisu';var name$4=KHR_TEXTURE_BASISU;function preprocess$2(gltfData,options){var scene=new GLTFScenegraph(gltfData);var json=scene.json;var _iterator21=_createForOfIteratorHelper(json.textures||[]),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;){var texture=_step21.value;var extension=scene.getObjectExtension(texture,KHR_TEXTURE_BASISU);if(extension){texture.source=extension.source;}scene.removeObjectExtension(texture,KHR_TEXTURE_BASISU);}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}scene.removeExtension(KHR_TEXTURE_BASISU);}var KHR_texture_basisu=/*#__PURE__*/Object.freeze({__proto__:null,name:name$4,preprocess:preprocess$2});var VERSION$1="3.2.6";var DEFAULT_DRACO_OPTIONS={draco:{decoderType:(typeof WebAssembly==="undefined"?"undefined":_typeof(WebAssembly))==='object'?'wasm':'js',libraryPath:'libs/',extraAttributes:{},attributeNameEntry:undefined}};var DracoLoader$1={name:'Draco',id:'draco',module:'draco',shapes:['mesh'],version:VERSION$1,worker:true,extensions:['drc'],mimeTypes:['application/octet-stream'],binary:true,tests:['DRACO'],options:DEFAULT_DRACO_OPTIONS};function getMeshBoundingBox(attributes){var minX=Infinity;var minY=Infinity;var minZ=Infinity;var maxX=-Infinity;var maxY=-Infinity;var maxZ=-Infinity;var positions=attributes.POSITION?attributes.POSITION.value:[];var len=positions&&positions.length;for(var _i517=0;_i517<len;_i517+=3){var x=positions[_i517];var y=positions[_i517+1];var _z4=positions[_i517+2];minX=x<minX?x:minX;minY=y<minY?y:minY;minZ=_z4<minZ?_z4:minZ;maxX=x>maxX?x:maxX;maxY=y>maxY?y:maxY;maxZ=_z4>maxZ?_z4:maxZ;}return[[minX,minY,minZ],[maxX,maxY,maxZ]];}function assert(condition,message){if(!condition){throw new Error(message||'loader assertion failed.');}}var Schema=/*#__PURE__*/function(){function Schema(fields,metadata){_classCallCheck(this,Schema);_defineProperty(this,"fields",void 0);_defineProperty(this,"metadata",void 0);assert(Array.isArray(fields));checkNames(fields);this.fields=fields;this.metadata=metadata||new Map();}_createClass(Schema,[{key:"compareTo",value:function compareTo(other){if(this.metadata!==other.metadata){return false;}if(this.fields.length!==other.fields.length){return false;}for(var _i518=0;_i518<this.fields.length;++_i518){if(!this.fields[_i518].compareTo(other.fields[_i518])){return false;}}return true;}},{key:"select",value:function select(){var nameMap=Object.create(null);for(var _len106=arguments.length,columnNames=new Array(_len106),_key11=0;_key11<_len106;_key11++){columnNames[_key11]=arguments[_key11];}for(var _i519=0,_columnNames=columnNames;_i519<_columnNames.length;_i519++){var _name6=_columnNames[_i519];nameMap[_name6]=true;}var selectedFields=this.fields.filter(function(field){return nameMap[field.name];});return new Schema(selectedFields,this.metadata);}},{key:"selectAt",value:function selectAt(){var _this124=this;for(var _len107=arguments.length,columnIndices=new Array(_len107),_key12=0;_key12<_len107;_key12++){columnIndices[_key12]=arguments[_key12];}var selectedFields=columnIndices.map(function(index){return _this124.fields[index];}).filter(Boolean);return new Schema(selectedFields,this.metadata);}},{key:"assign",value:function assign(schemaOrFields){var fields;var metadata=this.metadata;if(schemaOrFields instanceof Schema){var otherSchema=schemaOrFields;fields=otherSchema.fields;metadata=mergeMaps(mergeMaps(new Map(),this.metadata),otherSchema.metadata);}else{fields=schemaOrFields;}var fieldMap=Object.create(null);var _iterator22=_createForOfIteratorHelper(this.fields),_step22;try{for(_iterator22.s();!(_step22=_iterator22.n()).done;){var field=_step22.value;fieldMap[field.name]=field;}}catch(err){_iterator22.e(err);}finally{_iterator22.f();}var _iterator23=_createForOfIteratorHelper(fields),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var _field=_step23.value;fieldMap[_field.name]=_field;}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}var mergedFields=Object.values(fieldMap);return new Schema(mergedFields,metadata);}}]);return Schema;}();function checkNames(fields){var usedNames={};var _iterator24=_createForOfIteratorHelper(fields),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var field=_step24.value;if(usedNames[field.name]){console.warn('Schema: duplicated field name',field.name,field);}usedNames[field.name]=true;}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}}function mergeMaps(m1,m2){return new Map([].concat(_toConsumableArray(m1||new Map()),_toConsumableArray(m2||new Map())));}var Field=/*#__PURE__*/function(){function Field(name,type){var nullable=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var metadata=arguments.length>3&&arguments[3]!==undefined?arguments[3]:new Map();_classCallCheck(this,Field);_defineProperty(this,"name",void 0);_defineProperty(this,"type",void 0);_defineProperty(this,"nullable",void 0);_defineProperty(this,"metadata",void 0);this.name=name;this.type=type;this.nullable=nullable;this.metadata=metadata;}_createClass(Field,[{key:"typeId",get:function get(){return this.type&&this.type.typeId;}},{key:"clone",value:function clone(){return new Field(this.name,this.type,this.nullable,this.metadata);}},{key:"compareTo",value:function compareTo(other){return this.name===other.name&&this.type===other.type&&this.nullable===other.nullable&&this.metadata===other.metadata;}},{key:"toString",value:function toString(){return"".concat(this.type).concat(this.nullable?', nullable':'').concat(this.metadata?", metadata: ".concat(this.metadata):'');}}]);return Field;}();var Type;(function(Type){Type[Type["NONE"]=0]="NONE";Type[Type["Null"]=1]="Null";Type[Type["Int"]=2]="Int";Type[Type["Float"]=3]="Float";Type[Type["Binary"]=4]="Binary";Type[Type["Utf8"]=5]="Utf8";Type[Type["Bool"]=6]="Bool";Type[Type["Decimal"]=7]="Decimal";Type[Type["Date"]=8]="Date";Type[Type["Time"]=9]="Time";Type[Type["Timestamp"]=10]="Timestamp";Type[Type["Interval"]=11]="Interval";Type[Type["List"]=12]="List";Type[Type["Struct"]=13]="Struct";Type[Type["Union"]=14]="Union";Type[Type["FixedSizeBinary"]=15]="FixedSizeBinary";Type[Type["FixedSizeList"]=16]="FixedSizeList";Type[Type["Map"]=17]="Map";Type[Type["Dictionary"]=-1]="Dictionary";Type[Type["Int8"]=-2]="Int8";Type[Type["Int16"]=-3]="Int16";Type[Type["Int32"]=-4]="Int32";Type[Type["Int64"]=-5]="Int64";Type[Type["Uint8"]=-6]="Uint8";Type[Type["Uint16"]=-7]="Uint16";Type[Type["Uint32"]=-8]="Uint32";Type[Type["Uint64"]=-9]="Uint64";Type[Type["Float16"]=-10]="Float16";Type[Type["Float32"]=-11]="Float32";Type[Type["Float64"]=-12]="Float64";Type[Type["DateDay"]=-13]="DateDay";Type[Type["DateMillisecond"]=-14]="DateMillisecond";Type[Type["TimestampSecond"]=-15]="TimestampSecond";Type[Type["TimestampMillisecond"]=-16]="TimestampMillisecond";Type[Type["TimestampMicrosecond"]=-17]="TimestampMicrosecond";Type[Type["TimestampNanosecond"]=-18]="TimestampNanosecond";Type[Type["TimeSecond"]=-19]="TimeSecond";Type[Type["TimeMillisecond"]=-20]="TimeMillisecond";Type[Type["TimeMicrosecond"]=-21]="TimeMicrosecond";Type[Type["TimeNanosecond"]=-22]="TimeNanosecond";Type[Type["DenseUnion"]=-23]="DenseUnion";Type[Type["SparseUnion"]=-24]="SparseUnion";Type[Type["IntervalDayTime"]=-25]="IntervalDayTime";Type[Type["IntervalYearMonth"]=-26]="IntervalYearMonth";})(Type||(Type={}));var _Symbol$toStringTag,_Symbol$toStringTag2,_Symbol$toStringTag7;var DataType=/*#__PURE__*/function(){function DataType(){_classCallCheck(this,DataType);}_createClass(DataType,[{key:"typeId",get:function get(){return Type.NONE;}},{key:"compareTo",value:function compareTo(other){return this===other;}}],[{key:"isNull",value:function isNull(x){return x&&x.typeId===Type.Null;}},{key:"isInt",value:function isInt(x){return x&&x.typeId===Type.Int;}},{key:"isFloat",value:function isFloat(x){return x&&x.typeId===Type.Float;}},{key:"isBinary",value:function isBinary(x){return x&&x.typeId===Type.Binary;}},{key:"isUtf8",value:function isUtf8(x){return x&&x.typeId===Type.Utf8;}},{key:"isBool",value:function isBool(x){return x&&x.typeId===Type.Bool;}},{key:"isDecimal",value:function isDecimal(x){return x&&x.typeId===Type.Decimal;}},{key:"isDate",value:function isDate(x){return x&&x.typeId===Type.Date;}},{key:"isTime",value:function isTime(x){return x&&x.typeId===Type.Time;}},{key:"isTimestamp",value:function isTimestamp(x){return x&&x.typeId===Type.Timestamp;}},{key:"isInterval",value:function isInterval(x){return x&&x.typeId===Type.Interval;}},{key:"isList",value:function isList(x){return x&&x.typeId===Type.List;}},{key:"isStruct",value:function isStruct(x){return x&&x.typeId===Type.Struct;}},{key:"isUnion",value:function isUnion(x){return x&&x.typeId===Type.Union;}},{key:"isFixedSizeBinary",value:function isFixedSizeBinary(x){return x&&x.typeId===Type.FixedSizeBinary;}},{key:"isFixedSizeList",value:function isFixedSizeList(x){return x&&x.typeId===Type.FixedSizeList;}},{key:"isMap",value:function isMap(x){return x&&x.typeId===Type.Map;}},{key:"isDictionary",value:function isDictionary(x){return x&&x.typeId===Type.Dictionary;}}]);return DataType;}();_Symbol$toStringTag=Symbol.toStringTag;var Int=/*#__PURE__*/function(_DataType,_Symbol$toStringTag3){_inherits(Int,_DataType);var _super147=_createSuper(Int);function Int(isSigned,bitWidth){var _this125;_classCallCheck(this,Int);_this125=_super147.call(this);_defineProperty(_assertThisInitialized(_this125),"isSigned",void 0);_defineProperty(_assertThisInitialized(_this125),"bitWidth",void 0);_this125.isSigned=isSigned;_this125.bitWidth=bitWidth;return _this125;}_createClass(Int,[{key:"typeId",get:function get(){return Type.Int;}},{key:_Symbol$toStringTag3,get:function get(){return'Int';}},{key:"toString",value:function toString(){return"".concat(this.isSigned?'I':'Ui',"nt").concat(this.bitWidth);}}]);return Int;}(DataType,_Symbol$toStringTag);var Int8=/*#__PURE__*/function(_Int){_inherits(Int8,_Int);var _super148=_createSuper(Int8);function Int8(){_classCallCheck(this,Int8);return _super148.call(this,true,8);}return _createClass(Int8);}(Int);var Int16=/*#__PURE__*/function(_Int2){_inherits(Int16,_Int2);var _super149=_createSuper(Int16);function Int16(){_classCallCheck(this,Int16);return _super149.call(this,true,16);}return _createClass(Int16);}(Int);var Int32=/*#__PURE__*/function(_Int3){_inherits(Int32,_Int3);var _super150=_createSuper(Int32);function Int32(){_classCallCheck(this,Int32);return _super150.call(this,true,32);}return _createClass(Int32);}(Int);var Uint8=/*#__PURE__*/function(_Int4){_inherits(Uint8,_Int4);var _super151=_createSuper(Uint8);function Uint8(){_classCallCheck(this,Uint8);return _super151.call(this,false,8);}return _createClass(Uint8);}(Int);var Uint16=/*#__PURE__*/function(_Int5){_inherits(Uint16,_Int5);var _super152=_createSuper(Uint16);function Uint16(){_classCallCheck(this,Uint16);return _super152.call(this,false,16);}return _createClass(Uint16);}(Int);var Uint32=/*#__PURE__*/function(_Int6){_inherits(Uint32,_Int6);var _super153=_createSuper(Uint32);function Uint32(){_classCallCheck(this,Uint32);return _super153.call(this,false,32);}return _createClass(Uint32);}(Int);var Precision={HALF:16,SINGLE:32,DOUBLE:64};_Symbol$toStringTag2=Symbol.toStringTag;var Float=/*#__PURE__*/function(_DataType2,_Symbol$toStringTag4){_inherits(Float,_DataType2);var _super154=_createSuper(Float);function Float(precision){var _this126;_classCallCheck(this,Float);_this126=_super154.call(this);_defineProperty(_assertThisInitialized(_this126),"precision",void 0);_this126.precision=precision;return _this126;}_createClass(Float,[{key:"typeId",get:function get(){return Type.Float;}},{key:_Symbol$toStringTag4,get:function get(){return'Float';}},{key:"toString",value:function toString(){return"Float".concat(this.precision);}}]);return Float;}(DataType,_Symbol$toStringTag2);var Float32=/*#__PURE__*/function(_Float){_inherits(Float32,_Float);var _super155=_createSuper(Float32);function Float32(){_classCallCheck(this,Float32);return _super155.call(this,Precision.SINGLE);}return _createClass(Float32);}(Float);var Float64=/*#__PURE__*/function(_Float2){_inherits(Float64,_Float2);var _super156=_createSuper(Float64);function Float64(){_classCallCheck(this,Float64);return _super156.call(this,Precision.DOUBLE);}return _createClass(Float64);}(Float);_Symbol$toStringTag7=Symbol.toStringTag;var FixedSizeList=/*#__PURE__*/function(_DataType3,_Symbol$toStringTag5){_inherits(FixedSizeList,_DataType3);var _super157=_createSuper(FixedSizeList);function FixedSizeList(listSize,child){var _this127;_classCallCheck(this,FixedSizeList);_this127=_super157.call(this);_defineProperty(_assertThisInitialized(_this127),"listSize",void 0);_defineProperty(_assertThisInitialized(_this127),"children",void 0);_this127.listSize=listSize;_this127.children=[child];return _this127;}_createClass(FixedSizeList,[{key:"typeId",get:function get(){return Type.FixedSizeList;}},{key:"valueType",get:function get(){return this.children[0].type;}},{key:"valueField",get:function get(){return this.children[0];}},{key:_Symbol$toStringTag5,get:function get(){return'FixedSizeList';}},{key:"toString",value:function toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">");}}]);return FixedSizeList;}(DataType,_Symbol$toStringTag7);function getArrowTypeFromTypedArray(array){switch(array.constructor){case Int8Array:return new Int8();case Uint8Array:return new Uint8();case Int16Array:return new Int16();case Uint16Array:return new Uint16();case Int32Array:return new Int32();case Uint32Array:return new Uint32();case Float32Array:return new Float32();case Float64Array:return new Float64();default:throw new Error('array type not supported');}}function deduceMeshField(attributeName,attribute,optionalMetadata){var type=getArrowTypeFromTypedArray(attribute.value);var metadata=optionalMetadata?optionalMetadata:makeMeshAttributeMetadata(attribute);var field=new Field(attributeName,new FixedSizeList(attribute.size,new Field('value',type)),false,metadata);return field;}function makeMeshAttributeMetadata(attribute){var result=new Map();if('byteOffset'in attribute){result.set('byteOffset',attribute.byteOffset.toString(10));}if('byteStride'in attribute){result.set('byteStride',attribute.byteStride.toString(10));}if('normalized'in attribute){result.set('normalized',attribute.normalized.toString());}return result;}function getDracoSchema(attributes,loaderData,indices){var metadataMap=makeMetadata(loaderData.metadata);var fields=[];var namedLoaderDataAttributes=transformAttributesLoaderData(loaderData.attributes);for(var attributeName in attributes){var attribute=attributes[attributeName];var field=getArrowFieldFromAttribute(attributeName,attribute,namedLoaderDataAttributes[attributeName]);fields.push(field);}if(indices){var indicesField=getArrowFieldFromAttribute('indices',indices);fields.push(indicesField);}return new Schema(fields,metadataMap);}function transformAttributesLoaderData(loaderData){var result={};for(var key in loaderData){var dracoAttribute=loaderData[key];result[dracoAttribute.name||'undefined']=dracoAttribute;}return result;}function getArrowFieldFromAttribute(attributeName,attribute,loaderData){var metadataMap=loaderData?makeMetadata(loaderData.metadata):undefined;var field=deduceMeshField(attributeName,attribute,metadataMap);return field;}function makeMetadata(metadata){var metadataMap=new Map();for(var key in metadata){metadataMap.set("".concat(key,".string"),JSON.stringify(metadata[key]));}return metadataMap;}var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP={POSITION:'POSITION',NORMAL:'NORMAL',COLOR:'COLOR_0',TEX_COORD:'TEXCOORD_0'};var DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};var INDEX_ITEM_SIZE=4;var DracoParser=/*#__PURE__*/function(){function DracoParser(draco){_classCallCheck(this,DracoParser);_defineProperty(this,"draco",void 0);_defineProperty(this,"decoder",void 0);_defineProperty(this,"metadataQuerier",void 0);this.draco=draco;this.decoder=new this.draco.Decoder();this.metadataQuerier=new this.draco.MetadataQuerier();}_createClass(DracoParser,[{key:"destroy",value:function destroy(){this.draco.destroy(this.decoder);this.draco.destroy(this.metadataQuerier);}},{key:"parseSync",value:function parseSync(arrayBuffer){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var buffer=new this.draco.DecoderBuffer();buffer.Init(new Int8Array(arrayBuffer),arrayBuffer.byteLength);this._disableAttributeTransforms(options);var geometry_type=this.decoder.GetEncodedGeometryType(buffer);var dracoGeometry=geometry_type===this.draco.TRIANGULAR_MESH?new this.draco.Mesh():new this.draco.PointCloud();try{var dracoStatus;switch(geometry_type){case this.draco.TRIANGULAR_MESH:dracoStatus=this.decoder.DecodeBufferToMesh(buffer,dracoGeometry);break;case this.draco.POINT_CLOUD:dracoStatus=this.decoder.DecodeBufferToPointCloud(buffer,dracoGeometry);break;default:throw new Error('DRACO: Unknown geometry type.');}if(!dracoStatus.ok()||!dracoGeometry.ptr){var message="DRACO decompression failed: ".concat(dracoStatus.error_msg());throw new Error(message);}var loaderData=this._getDracoLoaderData(dracoGeometry,geometry_type,options);var geometry=this._getMeshData(dracoGeometry,loaderData,options);var boundingBox=getMeshBoundingBox(geometry.attributes);var schema=getDracoSchema(geometry.attributes,loaderData,geometry.indices);var data=_objectSpread(_objectSpread({loader:'draco',loaderData:loaderData,header:{vertexCount:dracoGeometry.num_points(),boundingBox:boundingBox}},geometry),{},{schema:schema});return data;}finally{this.draco.destroy(buffer);if(dracoGeometry){this.draco.destroy(dracoGeometry);}}}},{key:"_getDracoLoaderData",value:function _getDracoLoaderData(dracoGeometry,geometry_type,options){var metadata=this._getTopLevelMetadata(dracoGeometry);var attributes=this._getDracoAttributes(dracoGeometry,options);return{geometry_type:geometry_type,num_attributes:dracoGeometry.num_attributes(),num_points:dracoGeometry.num_points(),num_faces:dracoGeometry instanceof this.draco.Mesh?dracoGeometry.num_faces():0,metadata:metadata,attributes:attributes};}},{key:"_getDracoAttributes",value:function _getDracoAttributes(dracoGeometry,options){var dracoAttributes={};for(var attributeId=0;attributeId<dracoGeometry.num_attributes();attributeId++){var dracoAttribute=this.decoder.GetAttribute(dracoGeometry,attributeId);var metadata=this._getAttributeMetadata(dracoGeometry,attributeId);dracoAttributes[dracoAttribute.unique_id()]={unique_id:dracoAttribute.unique_id(),attribute_type:dracoAttribute.attribute_type(),data_type:dracoAttribute.data_type(),num_components:dracoAttribute.num_components(),byte_offset:dracoAttribute.byte_offset(),byte_stride:dracoAttribute.byte_stride(),normalized:dracoAttribute.normalized(),attribute_index:attributeId,metadata:metadata};var quantization=this._getQuantizationTransform(dracoAttribute,options);if(quantization){dracoAttributes[dracoAttribute.unique_id()].quantization_transform=quantization;}var octahedron=this._getOctahedronTransform(dracoAttribute,options);if(octahedron){dracoAttributes[dracoAttribute.unique_id()].octahedron_transform=octahedron;}}return dracoAttributes;}},{key:"_getMeshData",value:function _getMeshData(dracoGeometry,loaderData,options){var attributes=this._getMeshAttributes(loaderData,dracoGeometry,options);var positionAttribute=attributes.POSITION;if(!positionAttribute){throw new Error('DRACO: No position attribute found.');}if(dracoGeometry instanceof this.draco.Mesh){switch(options.topology){case'triangle-strip':return{topology:'triangle-strip',mode:4,attributes:attributes,indices:{value:this._getTriangleStripIndices(dracoGeometry),size:1}};case'triangle-list':default:return{topology:'triangle-list',mode:5,attributes:attributes,indices:{value:this._getTriangleListIndices(dracoGeometry),size:1}};}}return{topology:'point-list',mode:0,attributes:attributes};}},{key:"_getMeshAttributes",value:function _getMeshAttributes(loaderData,dracoGeometry,options){var attributes={};for(var _i520=0,_Object$values=Object.values(loaderData.attributes);_i520<_Object$values.length;_i520++){var loaderAttribute=_Object$values[_i520];var attributeName=this._deduceAttributeName(loaderAttribute,options);loaderAttribute.name=attributeName;var _this$_getAttributeVa=this._getAttributeValues(dracoGeometry,loaderAttribute),value=_this$_getAttributeVa.value,size=_this$_getAttributeVa.size;attributes[attributeName]={value:value,size:size,byteOffset:loaderAttribute.byte_offset,byteStride:loaderAttribute.byte_stride,normalized:loaderAttribute.normalized};}return attributes;}},{key:"_getTriangleListIndices",value:function _getTriangleListIndices(dracoGeometry){var numFaces=dracoGeometry.num_faces();var numIndices=numFaces*3;var byteLength=numIndices*INDEX_ITEM_SIZE;var ptr=this.draco._malloc(byteLength);try{this.decoder.GetTrianglesUInt32Array(dracoGeometry,byteLength,ptr);return new Uint32Array(this.draco.HEAPF32.buffer,ptr,numIndices).slice();}finally{this.draco._free(ptr);}}},{key:"_getTriangleStripIndices",value:function _getTriangleStripIndices(dracoGeometry){var dracoArray=new this.draco.DracoInt32Array();try{this.decoder.GetTriangleStripsFromMesh(dracoGeometry,dracoArray);return getUint32Array(dracoArray);}finally{this.draco.destroy(dracoArray);}}},{key:"_getAttributeValues",value:function _getAttributeValues(dracoGeometry,attribute){var TypedArrayCtor=DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];var numComponents=attribute.num_components;var numPoints=dracoGeometry.num_points();var numValues=numPoints*numComponents;var byteLength=numValues*TypedArrayCtor.BYTES_PER_ELEMENT;var dataType=getDracoDataType(this.draco,TypedArrayCtor);var value;var ptr=this.draco._malloc(byteLength);try{var dracoAttribute=this.decoder.GetAttribute(dracoGeometry,attribute.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry,dracoAttribute,dataType,byteLength,ptr);value=new TypedArrayCtor(this.draco.HEAPF32.buffer,ptr,numValues).slice();}finally{this.draco._free(ptr);}return{value:value,size:numComponents};}},{key:"_deduceAttributeName",value:function _deduceAttributeName(attribute,options){var uniqueId=attribute.unique_id;for(var _i521=0,_Object$entries4=Object.entries(options.extraAttributes||{});_i521<_Object$entries4.length;_i521++){var _Object$entries4$_i=_slicedToArray(_Object$entries4[_i521],2),attributeName=_Object$entries4$_i[0],attributeUniqueId=_Object$entries4$_i[1];if(attributeUniqueId===uniqueId){return attributeName;}}var thisAttributeType=attribute.attribute_type;for(var dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP){var attributeType=this.draco[dracoAttributeConstant];if(attributeType===thisAttributeType){return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant];}}var entryName=options.attributeNameEntry||'name';if(attribute.metadata[entryName]){return attribute.metadata[entryName].string;}return"CUSTOM_ATTRIBUTE_".concat(uniqueId);}},{key:"_getTopLevelMetadata",value:function _getTopLevelMetadata(dracoGeometry){var dracoMetadata=this.decoder.GetMetadata(dracoGeometry);return this._getDracoMetadata(dracoMetadata);}},{key:"_getAttributeMetadata",value:function _getAttributeMetadata(dracoGeometry,attributeId){var dracoMetadata=this.decoder.GetAttributeMetadata(dracoGeometry,attributeId);return this._getDracoMetadata(dracoMetadata);}},{key:"_getDracoMetadata",value:function _getDracoMetadata(dracoMetadata){if(!dracoMetadata||!dracoMetadata.ptr){return{};}var result={};var numEntries=this.metadataQuerier.NumEntries(dracoMetadata);for(var entryIndex=0;entryIndex<numEntries;entryIndex++){var entryName=this.metadataQuerier.GetEntryName(dracoMetadata,entryIndex);result[entryName]=this._getDracoMetadataField(dracoMetadata,entryName);}return result;}},{key:"_getDracoMetadataField",value:function _getDracoMetadataField(dracoMetadata,entryName){var dracoArray=new this.draco.DracoInt32Array();try{this.metadataQuerier.GetIntEntryArray(dracoMetadata,entryName,dracoArray);var intArray=getInt32Array(dracoArray);return{"int":this.metadataQuerier.GetIntEntry(dracoMetadata,entryName),string:this.metadataQuerier.GetStringEntry(dracoMetadata,entryName),"double":this.metadataQuerier.GetDoubleEntry(dracoMetadata,entryName),intArray:intArray};}finally{this.draco.destroy(dracoArray);}}},{key:"_disableAttributeTransforms",value:function _disableAttributeTransforms(options){var _options$quantizedAtt=options.quantizedAttributes,quantizedAttributes=_options$quantizedAtt===void 0?[]:_options$quantizedAtt,_options$octahedronAt=options.octahedronAttributes,octahedronAttributes=_options$octahedronAt===void 0?[]:_options$octahedronAt;var skipAttributes=[].concat(_toConsumableArray(quantizedAttributes),_toConsumableArray(octahedronAttributes));var _iterator25=_createForOfIteratorHelper(skipAttributes),_step25;try{for(_iterator25.s();!(_step25=_iterator25.n()).done;){var dracoAttributeName=_step25.value;this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);}}catch(err){_iterator25.e(err);}finally{_iterator25.f();}}},{key:"_getQuantizationTransform",value:function _getQuantizationTransform(dracoAttribute,options){var _this128=this;var _options$quantizedAtt2=options.quantizedAttributes,quantizedAttributes=_options$quantizedAtt2===void 0?[]:_options$quantizedAtt2;var attribute_type=dracoAttribute.attribute_type();var skip=quantizedAttributes.map(function(type){return _this128.decoder[type];}).includes(attribute_type);if(skip){var _transform2=new this.draco.AttributeQuantizationTransform();try{if(_transform2.InitFromAttribute(dracoAttribute)){return{quantization_bits:_transform2.quantization_bits(),range:_transform2.range(),min_values:new Float32Array([1,2,3]).map(function(i){return _transform2.min_value(i);})};}}finally{this.draco.destroy(_transform2);}}return null;}},{key:"_getOctahedronTransform",value:function _getOctahedronTransform(dracoAttribute,options){var _this129=this;var _options$octahedronAt2=options.octahedronAttributes,octahedronAttributes=_options$octahedronAt2===void 0?[]:_options$octahedronAt2;var attribute_type=dracoAttribute.attribute_type();var octahedron=octahedronAttributes.map(function(type){return _this129.decoder[type];}).includes(attribute_type);if(octahedron){var _transform3=new this.draco.AttributeQuantizationTransform();try{if(_transform3.InitFromAttribute(dracoAttribute)){return{quantization_bits:_transform3.quantization_bits()};}}finally{this.draco.destroy(_transform3);}}return null;}}]);return DracoParser;}();function getDracoDataType(draco,attributeType){switch(attributeType){case Float32Array:return draco.DT_FLOAT32;case Int8Array:return draco.DT_INT8;case Int16Array:return draco.DT_INT16;case Int32Array:return draco.DT_INT32;case Uint8Array:return draco.DT_UINT8;case Uint16Array:return draco.DT_UINT16;case Uint32Array:return draco.DT_UINT32;default:return draco.DT_INVALID;}}function getInt32Array(dracoArray){var numValues=dracoArray.size();var intArray=new Int32Array(numValues);for(var _i522=0;_i522<numValues;_i522++){intArray[_i522]=dracoArray.GetValue(_i522);}return intArray;}function getUint32Array(dracoArray){var numValues=dracoArray.size();var intArray=new Int32Array(numValues);for(var _i523=0;_i523<numValues;_i523++){intArray[_i523]=dracoArray.GetValue(_i523);}return intArray;}var DRACO_VERSION='1.4.1';var DRACO_JS_DECODER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_decoder.js");var DRACO_WASM_WRAPPER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_wasm_wrapper.js");var DRACO_WASM_DECODER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_decoder.wasm");var loadDecoderPromise;function loadDracoDecoderModule(_x68){return _loadDracoDecoderModule.apply(this,arguments);}function _loadDracoDecoderModule(){_loadDracoDecoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(options){var modules;return _regeneratorRuntime().wrap(function _callee38$(_context42){while(1){switch(_context42.prev=_context42.next){case 0:modules=options.modules||{};if(modules.draco3d){loadDecoderPromise=loadDecoderPromise||modules.draco3d.createDecoderModule({}).then(function(draco){return{draco:draco};});}else{loadDecoderPromise=loadDecoderPromise||loadDracoDecoder(options);}_context42.next=4;return loadDecoderPromise;case 4:return _context42.abrupt("return",_context42.sent);case 5:case"end":return _context42.stop();}}},_callee38);}));return _loadDracoDecoderModule.apply(this,arguments);}function loadDracoDecoder(_x69){return _loadDracoDecoder.apply(this,arguments);}function _loadDracoDecoder(){_loadDracoDecoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(options){var DracoDecoderModule,wasmBinary,_yield$Promise$all5,_yield$Promise$all6;return _regeneratorRuntime().wrap(function _callee39$(_context43){while(1){switch(_context43.prev=_context43.next){case 0:_context43.t0=options.draco&&options.draco.decoderType;_context43.next=_context43.t0==='js'?3:_context43.t0==='wasm'?7:7;break;case 3:_context43.next=5;return loadLibrary(DRACO_JS_DECODER_URL,'draco',options);case 5:DracoDecoderModule=_context43.sent;return _context43.abrupt("break",21);case 7:_context43.t1=Promise;_context43.next=10;return loadLibrary(DRACO_WASM_WRAPPER_URL,'draco',options);case 10:_context43.t2=_context43.sent;_context43.next=13;return loadLibrary(DRACO_WASM_DECODER_URL,'draco',options);case 13:_context43.t3=_context43.sent;_context43.t4=[_context43.t2,_context43.t3];_context43.next=17;return _context43.t1.all.call(_context43.t1,_context43.t4);case 17:_yield$Promise$all5=_context43.sent;_yield$Promise$all6=_slicedToArray(_yield$Promise$all5,2);DracoDecoderModule=_yield$Promise$all6[0];wasmBinary=_yield$Promise$all6[1];case 21:DracoDecoderModule=DracoDecoderModule||globalThis.DracoDecoderModule;_context43.next=24;return initializeDracoDecoder(DracoDecoderModule,wasmBinary);case 24:return _context43.abrupt("return",_context43.sent);case 25:case"end":return _context43.stop();}}},_callee39);}));return _loadDracoDecoder.apply(this,arguments);}function initializeDracoDecoder(DracoDecoderModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){DracoDecoderModule(_objectSpread(_objectSpread({},options),{},{onModuleLoaded:function onModuleLoaded(draco){return resolve({draco:draco});}}));});}({id:isBrowser$3?'draco-writer':'draco-writer-nodejs',name:'Draco compressed geometry writer',module:'draco',version:VERSION$1,worker:true,options:{draco:{},source:null}});var DracoLoader=_objectSpread(_objectSpread({},DracoLoader$1),{},{parse:parse$2});function parse$2(_x70,_x71){return _parse$2.apply(this,arguments);}function _parse$2(){_parse$2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(arrayBuffer,options){var _yield$loadDracoDecod,draco,dracoParser;return _regeneratorRuntime().wrap(function _callee40$(_context44){while(1){switch(_context44.prev=_context44.next){case 0:_context44.next=2;return loadDracoDecoderModule(options);case 2:_yield$loadDracoDecod=_context44.sent;draco=_yield$loadDracoDecod.draco;dracoParser=new DracoParser(draco);_context44.prev=5;return _context44.abrupt("return",dracoParser.parseSync(arrayBuffer,options===null||options===void 0?void 0:options.draco));case 7:_context44.prev=7;dracoParser.destroy();return _context44.finish(7);case 10:case"end":return _context44.stop();}}},_callee40,null,[[5,,7,10]]);}));return _parse$2.apply(this,arguments);}function getGLTFAccessors(attributes){var accessors={};for(var _name7 in attributes){var attribute=attributes[_name7];if(_name7!=='indices'){var glTFAccessor=getGLTFAccessor(attribute);accessors[_name7]=glTFAccessor;}}return accessors;}function getGLTFAccessor(attribute){var _getAccessorData=getAccessorData(attribute),buffer=_getAccessorData.buffer,size=_getAccessorData.size,count=_getAccessorData.count;var glTFAccessor={value:buffer,size:size,byteOffset:0,count:count,type:getAccessorTypeFromSize(size),componentType:getComponentTypeFromArray(buffer)};return glTFAccessor;}function getAccessorData(attribute){var buffer=attribute;var size=1;var count=0;if(attribute&&attribute.value){buffer=attribute.value;size=attribute.size||1;}if(buffer){if(!ArrayBuffer.isView(buffer)){buffer=toTypedArray(buffer,Float32Array);}count=buffer.length/size;}return{buffer:buffer,size:size,count:count};}function toTypedArray(array,ArrayType){var convertTypedArrays=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(!array){return null;}if(Array.isArray(array)){return new ArrayType(array);}if(convertTypedArrays&&!(array instanceof ArrayType)){return new ArrayType(array);}return array;}var KHR_DRACO_MESH_COMPRESSION='KHR_draco_mesh_compression';var name$3=KHR_DRACO_MESH_COMPRESSION;function preprocess$1(gltfData,options,context){var scenegraph=new GLTFScenegraph(gltfData);var _iterator26=_createForOfIteratorHelper(makeMeshPrimitiveIterator(scenegraph)),_step26;try{for(_iterator26.s();!(_step26=_iterator26.n()).done;){var _primitive=_step26.value;if(scenegraph.getObjectExtension(_primitive,KHR_DRACO_MESH_COMPRESSION));}}catch(err){_iterator26.e(err);}finally{_iterator26.f();}}function decode$3(_x72,_x73,_x74){return _decode$2.apply(this,arguments);}function _decode$2(){_decode$2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(gltfData,options,context){var _options$gltf,scenegraph,promises,_iterator50,_step50,_primitive5;return _regeneratorRuntime().wrap(function _callee41$(_context45){while(1){switch(_context45.prev=_context45.next){case 0:if(options!==null&&options!==void 0&&(_options$gltf=options.gltf)!==null&&_options$gltf!==void 0&&_options$gltf.decompressMeshes){_context45.next=2;break;}return _context45.abrupt("return");case 2:scenegraph=new GLTFScenegraph(gltfData);promises=[];_iterator50=_createForOfIteratorHelper(makeMeshPrimitiveIterator(scenegraph));try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){_primitive5=_step50.value;if(scenegraph.getObjectExtension(_primitive5,KHR_DRACO_MESH_COMPRESSION)){promises.push(decompressPrimitive(scenegraph,_primitive5,options,context));}}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}_context45.next=8;return Promise.all(promises);case 8:scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION);case 9:case"end":return _context45.stop();}}},_callee41);}));return _decode$2.apply(this,arguments);}function encode$3(gltfData){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var scenegraph=new GLTFScenegraph(gltfData);var _iterator27=_createForOfIteratorHelper(scenegraph.json.meshes||[]),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var _mesh3=_step27.value;compressMesh(_mesh3);scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION);}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}}function decompressPrimitive(_x75,_x76,_x77,_x78){return _decompressPrimitive.apply(this,arguments);}function _decompressPrimitive(){_decompressPrimitive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(scenegraph,primitive,options,context){var dracoExtension,buffer,bufferCopy,parse,dracoOptions,decodedData,decodedAttributes,_i620,_Object$entries6,_Object$entries6$_i,attributeName,decodedAttribute,accessorIndex,accessor;return _regeneratorRuntime().wrap(function _callee42$(_context46){while(1){switch(_context46.prev=_context46.next){case 0:dracoExtension=scenegraph.getObjectExtension(primitive,KHR_DRACO_MESH_COMPRESSION);if(dracoExtension){_context46.next=3;break;}return _context46.abrupt("return");case 3:buffer=scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);bufferCopy=sliceArrayBuffer(buffer.buffer,buffer.byteOffset);parse=context.parse;dracoOptions=_objectSpread({},options);delete dracoOptions['3d-tiles'];_context46.next=10;return parse(bufferCopy,DracoLoader,dracoOptions,context);case 10:decodedData=_context46.sent;decodedAttributes=getGLTFAccessors(decodedData.attributes);for(_i620=0,_Object$entries6=Object.entries(decodedAttributes);_i620<_Object$entries6.length;_i620++){_Object$entries6$_i=_slicedToArray(_Object$entries6[_i620],2),attributeName=_Object$entries6$_i[0],decodedAttribute=_Object$entries6$_i[1];if(attributeName in primitive.attributes){accessorIndex=primitive.attributes[attributeName];accessor=scenegraph.getAccessor(accessorIndex);if(accessor!==null&&accessor!==void 0&&accessor.min&&accessor!==null&&accessor!==void 0&&accessor.max){decodedAttribute.min=accessor.min;decodedAttribute.max=accessor.max;}}}primitive.attributes=decodedAttributes;if(decodedData.indices){primitive.indices=getGLTFAccessor(decodedData.indices);}checkPrimitive(primitive);case 16:case"end":return _context46.stop();}}},_callee42);}));return _decompressPrimitive.apply(this,arguments);}function compressMesh(attributes,indices){var mode=arguments.length>2&&arguments[2]!==undefined?arguments[2]:4;var options=arguments.length>3?arguments[3]:undefined;var context=arguments.length>4?arguments[4]:undefined;var _context$parseSync;if(!options.DracoWriter){throw new Error('options.gltf.DracoWriter not provided');}var compressedData=options.DracoWriter.encodeSync({attributes:attributes});var decodedData=context===null||context===void 0?void 0:(_context$parseSync=context.parseSync)===null||_context$parseSync===void 0?void 0:_context$parseSync.call(context,{attributes:attributes});var fauxAccessors=options._addFauxAttributes(decodedData.attributes);var bufferViewIndex=options.addBufferView(compressedData);var glTFMesh={primitives:[{attributes:fauxAccessors,mode:mode,extensions:_defineProperty2({},KHR_DRACO_MESH_COMPRESSION,{bufferView:bufferViewIndex,attributes:fauxAccessors})}]};return glTFMesh;}function checkPrimitive(primitive){if(!primitive.attributes&&Object.keys(primitive.attributes).length>0){throw new Error('glTF: Empty primitive detected: Draco decompression failure?');}}function makeMeshPrimitiveIterator(scenegraph){var _iterator28,_step28,_mesh4,_iterator29,_step29,_primitive2;return _regeneratorRuntime().wrap(function makeMeshPrimitiveIterator$(_context10){while(1){switch(_context10.prev=_context10.next){case 0:_iterator28=_createForOfIteratorHelper(scenegraph.json.meshes||[]);_context10.prev=1;_iterator28.s();case 3:if((_step28=_iterator28.n()).done){_context10.next=24;break;}_mesh4=_step28.value;_iterator29=_createForOfIteratorHelper(_mesh4.primitives);_context10.prev=6;_iterator29.s();case 8:if((_step29=_iterator29.n()).done){_context10.next=14;break;}_primitive2=_step29.value;_context10.next=12;return _primitive2;case 12:_context10.next=8;break;case 14:_context10.next=19;break;case 16:_context10.prev=16;_context10.t0=_context10["catch"](6);_iterator29.e(_context10.t0);case 19:_context10.prev=19;_iterator29.f();return _context10.finish(19);case 22:_context10.next=3;break;case 24:_context10.next=29;break;case 26:_context10.prev=26;_context10.t1=_context10["catch"](1);_iterator28.e(_context10.t1);case 29:_context10.prev=29;_iterator28.f();return _context10.finish(29);case 32:case"end":return _context10.stop();}}},_marked3,null,[[1,26,29,32],[6,16,19,22]]);}var KHR_draco_mesh_compression=/*#__PURE__*/Object.freeze({__proto__:null,name:name$3,preprocess:preprocess$1,decode:decode$3,encode:encode$3});var KHR_LIGHTS_PUNCTUAL='KHR_lights_punctual';var name$2=KHR_LIGHTS_PUNCTUAL;function decode$2(_x79){return _decode$3.apply(this,arguments);}function _decode$3(){_decode$3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(gltfData){var gltfScenegraph,json,extension,_iterator51,_step51,_node10,nodeExtension;return _regeneratorRuntime().wrap(function _callee43$(_context47){while(1){switch(_context47.prev=_context47.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;extension=gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);if(extension){gltfScenegraph.json.lights=extension.lights;gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL);}_iterator51=_createForOfIteratorHelper(json.nodes||[]);try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){_node10=_step51.value;nodeExtension=gltfScenegraph.getObjectExtension(_node10,KHR_LIGHTS_PUNCTUAL);if(nodeExtension){_node10.light=nodeExtension.light;}gltfScenegraph.removeObjectExtension(_node10,KHR_LIGHTS_PUNCTUAL);}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}case 6:case"end":return _context47.stop();}}},_callee43);}));return _decode$3.apply(this,arguments);}function encode$2(_x80){return _encode$.apply(this,arguments);}function _encode$(){_encode$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(gltfData){var gltfScenegraph,json,extension,_iterator52,_step52,light,_node11;return _regeneratorRuntime().wrap(function _callee44$(_context48){while(1){switch(_context48.prev=_context48.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;if(json.lights){extension=gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);assert$1(!extension.lights);extension.lights=json.lights;delete json.lights;}if(gltfScenegraph.json.lights){_iterator52=_createForOfIteratorHelper(gltfScenegraph.json.lights);try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){light=_step52.value;_node11=light.node;gltfScenegraph.addObjectExtension(_node11,KHR_LIGHTS_PUNCTUAL,light);}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}delete gltfScenegraph.json.lights;}case 4:case"end":return _context48.stop();}}},_callee44);}));return _encode$.apply(this,arguments);}var KHR_lights_punctual=/*#__PURE__*/Object.freeze({__proto__:null,name:name$2,decode:decode$2,encode:encode$2});var KHR_MATERIALS_UNLIT='KHR_materials_unlit';var name$1=KHR_MATERIALS_UNLIT;function decode$1(_x81){return _decode$4.apply(this,arguments);}function _decode$4(){_decode$4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(gltfData){var gltfScenegraph,json,_iterator53,_step53,material,extension;return _regeneratorRuntime().wrap(function _callee45$(_context49){while(1){switch(_context49.prev=_context49.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);_iterator53=_createForOfIteratorHelper(json.materials||[]);try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){material=_step53.value;extension=material.extensions&&material.extensions.KHR_materials_unlit;if(extension){material.unlit=true;}gltfScenegraph.removeObjectExtension(material,KHR_MATERIALS_UNLIT);}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}case 5:case"end":return _context49.stop();}}},_callee45);}));return _decode$4.apply(this,arguments);}function encode$1(gltfData){var gltfScenegraph=new GLTFScenegraph(gltfData);var json=gltfScenegraph.json;if(gltfScenegraph.materials){var _iterator30=_createForOfIteratorHelper(json.materials||[]),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var material=_step30.value;if(material.unlit){delete material.unlit;gltfScenegraph.addObjectExtension(material,KHR_MATERIALS_UNLIT,{});gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);}}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}}}var KHR_materials_unlit=/*#__PURE__*/Object.freeze({__proto__:null,name:name$1,decode:decode$1,encode:encode$1});var KHR_TECHNIQUES_WEBGL='KHR_techniques_webgl';var name=KHR_TECHNIQUES_WEBGL;function decode(_x82){return _decode.apply(this,arguments);}function _decode(){_decode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(gltfData){var gltfScenegraph,json,extension,techniques,_iterator54,_step54,material,materialExtension;return _regeneratorRuntime().wrap(function _callee46$(_context50){while(1){switch(_context50.prev=_context50.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;extension=gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);if(extension){techniques=resolveTechniques(extension,gltfScenegraph);_iterator54=_createForOfIteratorHelper(json.materials||[]);try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){material=_step54.value;materialExtension=gltfScenegraph.getObjectExtension(material,KHR_TECHNIQUES_WEBGL);if(materialExtension){material.technique=Object.assign({},materialExtension,techniques[materialExtension.technique]);material.technique.values=resolveValues(material.technique,gltfScenegraph);}gltfScenegraph.removeObjectExtension(material,KHR_TECHNIQUES_WEBGL);}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);}case 4:case"end":return _context50.stop();}}},_callee46);}));return _decode.apply(this,arguments);}function encode(_x83,_x84){return _encode.apply(this,arguments);}function _encode(){_encode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(gltfData,options){return _regeneratorRuntime().wrap(function _callee47$(_context51){while(1){switch(_context51.prev=_context51.next){case 0:case"end":return _context51.stop();}}},_callee47);}));return _encode.apply(this,arguments);}function resolveTechniques(techniquesExtension,gltfScenegraph){var _techniquesExtension$=techniquesExtension.programs,programs=_techniquesExtension$===void 0?[]:_techniquesExtension$,_techniquesExtension$2=techniquesExtension.shaders,shaders=_techniquesExtension$2===void 0?[]:_techniquesExtension$2,_techniquesExtension$3=techniquesExtension.techniques,techniques=_techniquesExtension$3===void 0?[]:_techniquesExtension$3;var textDecoder=new TextDecoder();shaders.forEach(function(shader){if(Number.isFinite(shader.bufferView)){shader.code=textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));}else{throw new Error('KHR_techniques_webgl: no shader code');}});programs.forEach(function(program){program.fragmentShader=shaders[program.fragmentShader];program.vertexShader=shaders[program.vertexShader];});techniques.forEach(function(technique){technique.program=programs[technique.program];});return techniques;}function resolveValues(technique,gltfScenegraph){var values=Object.assign({},technique.values);Object.keys(technique.uniforms||{}).forEach(function(uniform){if(technique.uniforms[uniform].value&&!(uniform in values)){values[uniform]=technique.uniforms[uniform].value;}});Object.keys(values).forEach(function(uniform){if(_typeof(values[uniform])==='object'&&values[uniform].index!==undefined){values[uniform].texture=gltfScenegraph.getTexture(values[uniform].index);}});return values;}var KHR_techniques_webgl=/*#__PURE__*/Object.freeze({__proto__:null,name:name,decode:decode,encode:encode});var EXTENSIONS=[EXT_meshopt_compression,EXT_texture_webp,KHR_texture_basisu,KHR_draco_mesh_compression,KHR_lights_punctual,KHR_materials_unlit,KHR_techniques_webgl];function preprocessExtensions(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var context=arguments.length>2?arguments[2]:undefined;var extensions=EXTENSIONS.filter(function(extension){return useExtension(extension.name,options);});var _iterator31=_createForOfIteratorHelper(extensions),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var extension=_step31.value;var _extension$preprocess;(_extension$preprocess=extension.preprocess)===null||_extension$preprocess===void 0?void 0:_extension$preprocess.call(extension,gltf,options,context);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}function decodeExtensions(_x85){return _decodeExtensions.apply(this,arguments);}function _decodeExtensions(){_decodeExtensions=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(gltf){var options,context,extensions,_iterator55,_step55,extension,_extension$decode,_args46=arguments;return _regeneratorRuntime().wrap(function _callee48$(_context52){while(1){switch(_context52.prev=_context52.next){case 0:options=_args46.length>1&&_args46[1]!==undefined?_args46[1]:{};context=_args46.length>2?_args46[2]:undefined;extensions=EXTENSIONS.filter(function(extension){return useExtension(extension.name,options);});_iterator55=_createForOfIteratorHelper(extensions);_context52.prev=4;_iterator55.s();case 6:if((_step55=_iterator55.n()).done){_context52.next=12;break;}extension=_step55.value;_context52.next=10;return(_extension$decode=extension.decode)===null||_extension$decode===void 0?void 0:_extension$decode.call(extension,gltf,options,context);case 10:_context52.next=6;break;case 12:_context52.next=17;break;case 14:_context52.prev=14;_context52.t0=_context52["catch"](4);_iterator55.e(_context52.t0);case 17:_context52.prev=17;_iterator55.f();return _context52.finish(17);case 20:case"end":return _context52.stop();}}},_callee48,null,[[4,14,17,20]]);}));return _decodeExtensions.apply(this,arguments);}function useExtension(extensionName,options){var _options$gltf;var excludes=(options===null||options===void 0?void 0:(_options$gltf=options.gltf)===null||_options$gltf===void 0?void 0:_options$gltf.excludeExtensions)||{};var exclude=extensionName in excludes&&!excludes[extensionName];return!exclude;}var KHR_BINARY_GLTF='KHR_binary_glTF';function preprocess(gltfData){var gltfScenegraph=new GLTFScenegraph(gltfData);var json=gltfScenegraph.json;var _iterator32=_createForOfIteratorHelper(json.images||[]),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _image7=_step32.value;var extension=gltfScenegraph.getObjectExtension(_image7,KHR_BINARY_GLTF);if(extension){Object.assign(_image7,extension);}gltfScenegraph.removeObjectExtension(_image7,KHR_BINARY_GLTF);}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}if(json.buffers&&json.buffers[0]){delete json.buffers[0].uri;}gltfScenegraph.removeExtension(KHR_BINARY_GLTF);}var GLTF_ARRAYS={accessors:'accessor',animations:'animation',buffers:'buffer',bufferViews:'bufferView',images:'image',materials:'material',meshes:'mesh',nodes:'node',samplers:'sampler',scenes:'scene',skins:'skin',textures:'texture'};var GLTF_KEYS={accessor:'accessors',animations:'animation',buffer:'buffers',bufferView:'bufferViews',image:'images',material:'materials',mesh:'meshes',node:'nodes',sampler:'samplers',scene:'scenes',skin:'skins',texture:'textures'};var GLTFV1Normalizer=/*#__PURE__*/function(){function GLTFV1Normalizer(){_classCallCheck(this,GLTFV1Normalizer);_defineProperty(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}});_defineProperty(this,"json",void 0);}_createClass(GLTFV1Normalizer,[{key:"normalize",value:function normalize(gltf,options){this.json=gltf.json;var json=gltf.json;switch(json.asset&&json.asset.version){case'2.0':return;case undefined:case'1.0':break;default:console.warn("glTF: Unknown version ".concat(json.asset.version));return;}if(!options.normalize){throw new Error('glTF v1 is not supported.');}console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');this._addAsset(json);this._convertTopLevelObjectsToArrays(json);preprocess(gltf);this._convertObjectIdsToArrayIndices(json);this._updateObjects(json);this._updateMaterial(json);}},{key:"_addAsset",value:function _addAsset(json){json.asset=json.asset||{};json.asset.version='2.0';json.asset.generator=json.asset.generator||'Normalized to glTF 2.0 by loaders.gl';}},{key:"_convertTopLevelObjectsToArrays",value:function _convertTopLevelObjectsToArrays(json){for(var arrayName in GLTF_ARRAYS){this._convertTopLevelObjectToArray(json,arrayName);}}},{key:"_convertTopLevelObjectToArray",value:function _convertTopLevelObjectToArray(json,mapName){var objectMap=json[mapName];if(!objectMap||Array.isArray(objectMap)){return;}json[mapName]=[];for(var id in objectMap){var object=objectMap[id];object.id=object.id||id;var index=json[mapName].length;json[mapName].push(object);this.idToIndexMap[mapName][id]=index;}}},{key:"_convertObjectIdsToArrayIndices",value:function _convertObjectIdsToArrayIndices(json){for(var arrayName in GLTF_ARRAYS){this._convertIdsToIndices(json,arrayName);}if('scene'in json){json.scene=this._convertIdToIndex(json.scene,'scene');}var _iterator33=_createForOfIteratorHelper(json.textures),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var texture=_step33.value;this._convertTextureIds(texture);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}var _iterator34=_createForOfIteratorHelper(json.meshes),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _mesh5=_step34.value;this._convertMeshIds(_mesh5);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}var _iterator35=_createForOfIteratorHelper(json.nodes),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var _node4=_step35.value;this._convertNodeIds(_node4);}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}var _iterator36=_createForOfIteratorHelper(json.scenes),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _node5=_step36.value;this._convertSceneIds(_node5);}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}}},{key:"_convertTextureIds",value:function _convertTextureIds(texture){if(texture.source){texture.source=this._convertIdToIndex(texture.source,'image');}}},{key:"_convertMeshIds",value:function _convertMeshIds(mesh){var _iterator37=_createForOfIteratorHelper(mesh.primitives),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var _primitive3=_step37.value;var attributes=_primitive3.attributes,indices=_primitive3.indices,material=_primitive3.material;for(var attributeName in attributes){attributes[attributeName]=this._convertIdToIndex(attributes[attributeName],'accessor');}if(indices){_primitive3.indices=this._convertIdToIndex(indices,'accessor');}if(material){_primitive3.material=this._convertIdToIndex(material,'material');}}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}}},{key:"_convertNodeIds",value:function _convertNodeIds(node){var _this130=this;if(node.children){node.children=node.children.map(function(child){return _this130._convertIdToIndex(child,'node');});}if(node.meshes){node.meshes=node.meshes.map(function(mesh){return _this130._convertIdToIndex(mesh,'mesh');});}}},{key:"_convertSceneIds",value:function _convertSceneIds(scene){var _this131=this;if(scene.nodes){scene.nodes=scene.nodes.map(function(node){return _this131._convertIdToIndex(node,'node');});}}},{key:"_convertIdsToIndices",value:function _convertIdsToIndices(json,topLevelArrayName){if(!json[topLevelArrayName]){console.warn("gltf v1: json doesn't contain attribute ".concat(topLevelArrayName));json[topLevelArrayName]=[];}var _iterator38=_createForOfIteratorHelper(json[topLevelArrayName]),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var object=_step38.value;for(var key in object){var id=object[key];var index=this._convertIdToIndex(id,key);object[key]=index;}}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}}},{key:"_convertIdToIndex",value:function _convertIdToIndex(id,key){var arrayName=GLTF_KEYS[key];if(arrayName in this.idToIndexMap){var index=this.idToIndexMap[arrayName][id];if(!Number.isFinite(index)){throw new Error("gltf v1: failed to resolve ".concat(key," with id ").concat(id));}return index;}return id;}},{key:"_updateObjects",value:function _updateObjects(json){var _iterator39=_createForOfIteratorHelper(this.json.buffers),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var buffer=_step39.value;delete buffer.type;}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}}},{key:"_updateMaterial",value:function _updateMaterial(json){var _iterator40=_createForOfIteratorHelper(json.materials),_step40;try{var _loop6=function _loop6(){var material=_step40.value;material.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};var textureId=((_material$values=material.values)===null||_material$values===void 0?void 0:_material$values.tex)||((_material$values2=material.values)===null||_material$values2===void 0?void 0:_material$values2.texture2d_0);var textureIndex=json.textures.findIndex(function(texture){return texture.id===textureId;});if(textureIndex!==-1){material.pbrMetallicRoughness.baseColorTexture={index:textureIndex};}};for(_iterator40.s();!(_step40=_iterator40.n()).done;){var _material$values,_material$values2;_loop6();}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}}]);return GLTFV1Normalizer;}();function normalizeGLTFV1(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return new GLTFV1Normalizer().normalize(gltf,options);}var COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var BYTES={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var GL_SAMPLER={TEXTURE_MAG_FILTER:0x2800,TEXTURE_MIN_FILTER:0x2801,TEXTURE_WRAP_S:0x2802,TEXTURE_WRAP_T:0x2803,REPEAT:0x2901,LINEAR:0x2601,NEAREST_MIPMAP_LINEAR:0x2702};var SAMPLER_PARAMETER_GLTF_TO_GL={magFilter:GL_SAMPLER.TEXTURE_MAG_FILTER,minFilter:GL_SAMPLER.TEXTURE_MIN_FILTER,wrapS:GL_SAMPLER.TEXTURE_WRAP_S,wrapT:GL_SAMPLER.TEXTURE_WRAP_T};var DEFAULT_SAMPLER=(_DEFAULT_SAMPLER={},_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_MAG_FILTER,GL_SAMPLER.LINEAR),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_MIN_FILTER,GL_SAMPLER.NEAREST_MIPMAP_LINEAR),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_WRAP_S,GL_SAMPLER.REPEAT),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_WRAP_T,GL_SAMPLER.REPEAT),_DEFAULT_SAMPLER);function getBytesFromComponentType(componentType){return BYTES[componentType];}function getSizeFromAccessorType(type){return COMPONENTS[type];}var GLTFPostProcessor=/*#__PURE__*/function(){function GLTFPostProcessor(){_classCallCheck(this,GLTFPostProcessor);_defineProperty(this,"baseUri",'');_defineProperty(this,"json",{});_defineProperty(this,"buffers",[]);_defineProperty(this,"images",[]);}_createClass(GLTFPostProcessor,[{key:"postProcess",value:function postProcess(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var json=gltf.json,_gltf$buffers=gltf.buffers,buffers=_gltf$buffers===void 0?[]:_gltf$buffers,_gltf$images=gltf.images,images=_gltf$images===void 0?[]:_gltf$images,_gltf$baseUri=gltf.baseUri,baseUri=_gltf$baseUri===void 0?'':_gltf$baseUri;assert$1(json);this.baseUri=baseUri;this.json=json;this.buffers=buffers;this.images=images;this._resolveTree(this.json,options);return this.json;}},{key:"_resolveTree",value:function _resolveTree(json){var _this132=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(json.bufferViews){json.bufferViews=json.bufferViews.map(function(bufView,i){return _this132._resolveBufferView(bufView,i);});}if(json.images){json.images=json.images.map(function(image,i){return _this132._resolveImage(image,i);});}if(json.samplers){json.samplers=json.samplers.map(function(sampler,i){return _this132._resolveSampler(sampler,i);});}if(json.textures){json.textures=json.textures.map(function(texture,i){return _this132._resolveTexture(texture,i);});}if(json.accessors){json.accessors=json.accessors.map(function(accessor,i){return _this132._resolveAccessor(accessor,i);});}if(json.materials){json.materials=json.materials.map(function(material,i){return _this132._resolveMaterial(material,i);});}if(json.meshes){json.meshes=json.meshes.map(function(mesh,i){return _this132._resolveMesh(mesh,i);});}if(json.nodes){json.nodes=json.nodes.map(function(node,i){return _this132._resolveNode(node,i);});}if(json.skins){json.skins=json.skins.map(function(skin,i){return _this132._resolveSkin(skin,i);});}if(json.scenes){json.scenes=json.scenes.map(function(scene,i){return _this132._resolveScene(scene,i);});}if(json.scene!==undefined){json.scene=json.scenes[this.json.scene];}}},{key:"getScene",value:function getScene(index){return this._get('scenes',index);}},{key:"getNode",value:function getNode(index){return this._get('nodes',index);}},{key:"getSkin",value:function getSkin(index){return this._get('skins',index);}},{key:"getMesh",value:function getMesh(index){return this._get('meshes',index);}},{key:"getMaterial",value:function getMaterial(index){return this._get('materials',index);}},{key:"getAccessor",value:function getAccessor(index){return this._get('accessors',index);}},{key:"getCamera",value:function getCamera(index){return null;}},{key:"getTexture",value:function getTexture(index){return this._get('textures',index);}},{key:"getSampler",value:function getSampler(index){return this._get('samplers',index);}},{key:"getImage",value:function getImage(index){return this._get('images',index);}},{key:"getBufferView",value:function getBufferView(index){return this._get('bufferViews',index);}},{key:"getBuffer",value:function getBuffer(index){return this._get('buffers',index);}},{key:"_get",value:function _get(array,index){if(_typeof(index)==='object'){return index;}var object=this.json[array]&&this.json[array][index];if(!object){console.warn("glTF file error: Could not find ".concat(array,"[").concat(index,"]"));}return object;}},{key:"_resolveScene",value:function _resolveScene(scene,index){var _this133=this;scene.id=scene.id||"scene-".concat(index);scene.nodes=(scene.nodes||[]).map(function(node){return _this133.getNode(node);});return scene;}},{key:"_resolveNode",value:function _resolveNode(node,index){var _this134=this;node.id=node.id||"node-".concat(index);if(node.children){node.children=node.children.map(function(child){return _this134.getNode(child);});}if(node.mesh!==undefined){node.mesh=this.getMesh(node.mesh);}else if(node.meshes!==undefined&&node.meshes.length){node.mesh=node.meshes.reduce(function(accum,meshIndex){var mesh=_this134.getMesh(meshIndex);accum.id=mesh.id;accum.primitives=accum.primitives.concat(mesh.primitives);return accum;},{primitives:[]});}if(node.camera!==undefined){node.camera=this.getCamera(node.camera);}if(node.skin!==undefined){node.skin=this.getSkin(node.skin);}return node;}},{key:"_resolveSkin",value:function _resolveSkin(skin,index){skin.id=skin.id||"skin-".concat(index);skin.inverseBindMatrices=this.getAccessor(skin.inverseBindMatrices);return skin;}},{key:"_resolveMesh",value:function _resolveMesh(mesh,index){var _this135=this;mesh.id=mesh.id||"mesh-".concat(index);if(mesh.primitives){mesh.primitives=mesh.primitives.map(function(primitive){primitive=_objectSpread({},primitive);var attributes=primitive.attributes;primitive.attributes={};for(var attribute in attributes){primitive.attributes[attribute]=_this135.getAccessor(attributes[attribute]);}if(primitive.indices!==undefined){primitive.indices=_this135.getAccessor(primitive.indices);}if(primitive.material!==undefined){primitive.material=_this135.getMaterial(primitive.material);}return primitive;});}return mesh;}},{key:"_resolveMaterial",value:function _resolveMaterial(material,index){material.id=material.id||"material-".concat(index);if(material.normalTexture){material.normalTexture=_objectSpread({},material.normalTexture);material.normalTexture.texture=this.getTexture(material.normalTexture.index);}if(material.occlusionTexture){material.occlustionTexture=_objectSpread({},material.occlustionTexture);material.occlusionTexture.texture=this.getTexture(material.occlusionTexture.index);}if(material.emissiveTexture){material.emmisiveTexture=_objectSpread({},material.emmisiveTexture);material.emissiveTexture.texture=this.getTexture(material.emissiveTexture.index);}if(!material.emissiveFactor){material.emissiveFactor=material.emmisiveTexture?[1,1,1]:[0,0,0];}if(material.pbrMetallicRoughness){material.pbrMetallicRoughness=_objectSpread({},material.pbrMetallicRoughness);var mr=material.pbrMetallicRoughness;if(mr.baseColorTexture){mr.baseColorTexture=_objectSpread({},mr.baseColorTexture);mr.baseColorTexture.texture=this.getTexture(mr.baseColorTexture.index);}if(mr.metallicRoughnessTexture){mr.metallicRoughnessTexture=_objectSpread({},mr.metallicRoughnessTexture);mr.metallicRoughnessTexture.texture=this.getTexture(mr.metallicRoughnessTexture.index);}}return material;}},{key:"_resolveAccessor",value:function _resolveAccessor(accessor,index){accessor.id=accessor.id||"accessor-".concat(index);if(accessor.bufferView!==undefined){accessor.bufferView=this.getBufferView(accessor.bufferView);}accessor.bytesPerComponent=getBytesFromComponentType(accessor.componentType);accessor.components=getSizeFromAccessorType(accessor.type);accessor.bytesPerElement=accessor.bytesPerComponent*accessor.components;if(accessor.bufferView){var buffer=accessor.bufferView.buffer;var _getAccessorArrayType2=getAccessorArrayTypeAndLength(accessor,accessor.bufferView),ArrayType=_getAccessorArrayType2.ArrayType,byteLength=_getAccessorArrayType2.byteLength;var byteOffset=(accessor.bufferView.byteOffset||0)+(accessor.byteOffset||0)+buffer.byteOffset;var cutBuffer=buffer.arrayBuffer.slice(byteOffset,byteOffset+byteLength);if(accessor.bufferView.byteStride){cutBuffer=this._getValueFromInterleavedBuffer(buffer,byteOffset,accessor.bufferView.byteStride,accessor.bytesPerElement,accessor.count);}accessor.value=new ArrayType(cutBuffer);}return accessor;}},{key:"_getValueFromInterleavedBuffer",value:function _getValueFromInterleavedBuffer(buffer,byteOffset,byteStride,bytesPerElement,count){var result=new Uint8Array(count*bytesPerElement);for(var _i524=0;_i524<count;_i524++){var elementOffset=byteOffset+_i524*byteStride;result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset,elementOffset+bytesPerElement)),_i524*bytesPerElement);}return result.buffer;}},{key:"_resolveTexture",value:function _resolveTexture(texture,index){texture.id=texture.id||"texture-".concat(index);texture.sampler='sampler'in texture?this.getSampler(texture.sampler):DEFAULT_SAMPLER;texture.source=this.getImage(texture.source);return texture;}},{key:"_resolveSampler",value:function _resolveSampler(sampler,index){sampler.id=sampler.id||"sampler-".concat(index);sampler.parameters={};for(var key in sampler){var glEnum=this._enumSamplerParameter(key);if(glEnum!==undefined){sampler.parameters[glEnum]=sampler[key];}}return sampler;}},{key:"_enumSamplerParameter",value:function _enumSamplerParameter(key){return SAMPLER_PARAMETER_GLTF_TO_GL[key];}},{key:"_resolveImage",value:function _resolveImage(image,index){image.id=image.id||"image-".concat(index);if(image.bufferView!==undefined){image.bufferView=this.getBufferView(image.bufferView);}var preloadedImage=this.images[index];if(preloadedImage){image.image=preloadedImage;}return image;}},{key:"_resolveBufferView",value:function _resolveBufferView(bufferView,index){var bufferIndex=bufferView.buffer;var result=_objectSpread(_objectSpread({id:"bufferView-".concat(index)},bufferView),{},{buffer:this.buffers[bufferIndex]});var arrayBuffer=this.buffers[bufferIndex].arrayBuffer;var byteOffset=this.buffers[bufferIndex].byteOffset||0;if('byteOffset'in bufferView){byteOffset+=bufferView.byteOffset;}result.data=new Uint8Array(arrayBuffer,byteOffset,bufferView.byteLength);return result;}},{key:"_resolveCamera",value:function _resolveCamera(camera,index){camera.id=camera.id||"camera-".concat(index);if(camera.perspective);if(camera.orthographic);return camera;}}]);return GLTFPostProcessor;}();function postProcessGLTF(gltf,options){return new GLTFPostProcessor().postProcess(gltf,options);}var MAGIC_glTF=0x676c5446;var GLB_FILE_HEADER_SIZE=12;var GLB_CHUNK_HEADER_SIZE=8;var GLB_CHUNK_TYPE_JSON=0x4e4f534a;var GLB_CHUNK_TYPE_BIN=0x004e4942;var GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED=0;var GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED=1;var GLB_V1_CONTENT_FORMAT_JSON=0x0;var LE=true;function getMagicString(dataView){var byteOffset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return"".concat(String.fromCharCode(dataView.getUint8(byteOffset+0))).concat(String.fromCharCode(dataView.getUint8(byteOffset+1))).concat(String.fromCharCode(dataView.getUint8(byteOffset+2))).concat(String.fromCharCode(dataView.getUint8(byteOffset+3)));}function isGLB(arrayBuffer){var byteOffset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var dataView=new DataView(arrayBuffer);var _options$magic=options.magic,magic=_options$magic===void 0?MAGIC_glTF:_options$magic;var magic1=dataView.getUint32(byteOffset,false);return magic1===magic||magic1===MAGIC_glTF;}function parseGLBSync(glb,arrayBuffer){var byteOffset=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var options=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var dataView=new DataView(arrayBuffer);var type=getMagicString(dataView,byteOffset+0);var version=dataView.getUint32(byteOffset+4,LE);var byteLength=dataView.getUint32(byteOffset+8,LE);Object.assign(glb,{header:{byteOffset:byteOffset,byteLength:byteLength,hasBinChunk:false},type:type,version:version,json:{},binChunks:[]});byteOffset+=GLB_FILE_HEADER_SIZE;switch(glb.version){case 1:return parseGLBV1(glb,dataView,byteOffset);case 2:return parseGLBV2(glb,dataView,byteOffset,options={});default:throw new Error("Invalid GLB version ".concat(glb.version,". Only supports v1 and v2."));}}function parseGLBV1(glb,dataView,byteOffset){assert$5(glb.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE);var contentLength=dataView.getUint32(byteOffset+0,LE);var contentFormat=dataView.getUint32(byteOffset+4,LE);byteOffset+=GLB_CHUNK_HEADER_SIZE;assert$5(contentFormat===GLB_V1_CONTENT_FORMAT_JSON);parseJSONChunk(glb,dataView,byteOffset,contentLength);byteOffset+=contentLength;byteOffset+=parseBINChunk(glb,dataView,byteOffset,glb.header.byteLength);return byteOffset;}function parseGLBV2(glb,dataView,byteOffset,options){assert$5(glb.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE);parseGLBChunksSync(glb,dataView,byteOffset,options);return byteOffset+glb.header.byteLength;}function parseGLBChunksSync(glb,dataView,byteOffset,options){while(byteOffset+8<=glb.header.byteLength){var chunkLength=dataView.getUint32(byteOffset+0,LE);var chunkFormat=dataView.getUint32(byteOffset+4,LE);byteOffset+=GLB_CHUNK_HEADER_SIZE;switch(chunkFormat){case GLB_CHUNK_TYPE_JSON:parseJSONChunk(glb,dataView,byteOffset,chunkLength);break;case GLB_CHUNK_TYPE_BIN:parseBINChunk(glb,dataView,byteOffset,chunkLength);break;case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:if(!options.strict){parseJSONChunk(glb,dataView,byteOffset,chunkLength);}break;case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:if(!options.strict){parseBINChunk(glb,dataView,byteOffset,chunkLength);}break;}byteOffset+=padToNBytes(chunkLength,4);}return byteOffset;}function parseJSONChunk(glb,dataView,byteOffset,chunkLength){var jsonChunk=new Uint8Array(dataView.buffer,byteOffset,chunkLength);var textDecoder=new TextDecoder('utf8');var jsonText=textDecoder.decode(jsonChunk);glb.json=JSON.parse(jsonText);return padToNBytes(chunkLength,4);}function parseBINChunk(glb,dataView,byteOffset,chunkLength){glb.header.hasBinChunk=true;glb.binChunks.push({byteOffset:byteOffset,byteLength:chunkLength,arrayBuffer:dataView.buffer});return padToNBytes(chunkLength,4);}function parseGLTF$1(_x86,_x87){return _parseGLTF$.apply(this,arguments);}function _parseGLTF$(){_parseGLTF$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(gltf,arrayBufferOrString){var byteOffset,options,context,_options$gltf,_options$gltf2,_options$gltf3,_options$gltf4,promises,_promise,promise,_args47=arguments;return _regeneratorRuntime().wrap(function _callee49$(_context53){while(1){switch(_context53.prev=_context53.next){case 0:byteOffset=_args47.length>2&&_args47[2]!==undefined?_args47[2]:0;options=_args47.length>3?_args47[3]:undefined;context=_args47.length>4?_args47[4]:undefined;parseGLTFContainerSync(gltf,arrayBufferOrString,byteOffset,options);normalizeGLTFV1(gltf,{normalize:options===null||options===void 0?void 0:(_options$gltf=options.gltf)===null||_options$gltf===void 0?void 0:_options$gltf.normalize});preprocessExtensions(gltf,options,context);promises=[];if(!(options!==null&&options!==void 0&&(_options$gltf2=options.gltf)!==null&&_options$gltf2!==void 0&&_options$gltf2.loadBuffers&&gltf.json.buffers)){_context53.next=10;break;}_context53.next=10;return loadBuffers(gltf,options,context);case 10:if(options!==null&&options!==void 0&&(_options$gltf3=options.gltf)!==null&&_options$gltf3!==void 0&&_options$gltf3.loadImages){_promise=loadImages(gltf,options,context);promises.push(_promise);}promise=decodeExtensions(gltf,options,context);promises.push(promise);_context53.next=15;return Promise.all(promises);case 15:return _context53.abrupt("return",options!==null&&options!==void 0&&(_options$gltf4=options.gltf)!==null&&_options$gltf4!==void 0&&_options$gltf4.postProcess?postProcessGLTF(gltf,options):gltf);case 16:case"end":return _context53.stop();}}},_callee49);}));return _parseGLTF$.apply(this,arguments);}function parseGLTFContainerSync(gltf,data,byteOffset,options){if(options.uri){gltf.baseUri=options.uri;}if(data instanceof ArrayBuffer&&!isGLB(data,byteOffset,options)){var textDecoder=new TextDecoder();data=textDecoder.decode(data);}if(typeof data==='string'){gltf.json=parseJSON(data);}else if(data instanceof ArrayBuffer){var glb={};byteOffset=parseGLBSync(glb,data,byteOffset,options.glb);assert$1(glb.type==='glTF',"Invalid GLB magic string ".concat(glb.type));gltf._glb=glb;gltf.json=glb.json;}else{assert$1(false,'GLTF: must be ArrayBuffer or string');}var buffers=gltf.json.buffers||[];gltf.buffers=new Array(buffers.length).fill(null);if(gltf._glb&&gltf._glb.header.hasBinChunk){var binChunks=gltf._glb.binChunks;gltf.buffers[0]={arrayBuffer:binChunks[0].arrayBuffer,byteOffset:binChunks[0].byteOffset,byteLength:binChunks[0].byteLength};}var images=gltf.json.images||[];gltf.images=new Array(images.length).fill({});}function loadBuffers(_x88,_x89,_x90){return _loadBuffers.apply(this,arguments);}function _loadBuffers(){_loadBuffers=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(gltf,options,context){var buffers,_i621,buffer,_context$fetch,_response$arrayBuffer,_fetch,uri,response,arrayBuffer;return _regeneratorRuntime().wrap(function _callee50$(_context54){while(1){switch(_context54.prev=_context54.next){case 0:buffers=gltf.json.buffers||[];_i621=0;case 2:if(!(_i621<buffers.length)){_context54.next=22;break;}buffer=buffers[_i621];if(!buffer.uri){_context54.next=18;break;}_fetch=context.fetch;assert$1(_fetch);uri=resolveUrl(buffer.uri,options);_context54.next=10;return context===null||context===void 0?void 0:(_context$fetch=context.fetch)===null||_context$fetch===void 0?void 0:_context$fetch.call(context,uri);case 10:response=_context54.sent;_context54.next=13;return response===null||response===void 0?void 0:(_response$arrayBuffer=response.arrayBuffer)===null||_response$arrayBuffer===void 0?void 0:_response$arrayBuffer.call(response);case 13:arrayBuffer=_context54.sent;gltf.buffers[_i621]={arrayBuffer:arrayBuffer,byteOffset:0,byteLength:arrayBuffer.byteLength};delete buffer.uri;_context54.next=19;break;case 18:if(gltf.buffers[_i621]===null){gltf.buffers[_i621]={arrayBuffer:new ArrayBuffer(buffer.byteLength),byteOffset:0,byteLength:buffer.byteLength};}case 19:++_i621;_context54.next=2;break;case 22:case"end":return _context54.stop();}}},_callee50);}));return _loadBuffers.apply(this,arguments);}function loadImages(_x91,_x92,_x93){return _loadImages.apply(this,arguments);}function _loadImages(){_loadImages=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(gltf,options,context){var imageIndices,images,promises,_iterator56,_step56,imageIndex;return _regeneratorRuntime().wrap(function _callee51$(_context55){while(1){switch(_context55.prev=_context55.next){case 0:imageIndices=getReferencesImageIndices(gltf);images=gltf.json.images||[];promises=[];_iterator56=_createForOfIteratorHelper(imageIndices);try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){imageIndex=_step56.value;promises.push(loadImage(gltf,images[imageIndex],imageIndex,options,context));}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}_context55.next=7;return Promise.all(promises);case 7:return _context55.abrupt("return",_context55.sent);case 8:case"end":return _context55.stop();}}},_callee51);}));return _loadImages.apply(this,arguments);}function getReferencesImageIndices(gltf){var imageIndices=new Set();var textures=gltf.json.textures||[];var _iterator41=_createForOfIteratorHelper(textures),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var texture=_step41.value;if(texture.source!==undefined){imageIndices.add(texture.source);}}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}return Array.from(imageIndices).sort();}function loadImage(_x94,_x95,_x96,_x97,_x98){return _loadImage.apply(this,arguments);}function _loadImage(){_loadImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(gltf,image,index,options,context){var fetch,parse,arrayBuffer,uri,response,array,parsedImage;return _regeneratorRuntime().wrap(function _callee52$(_context56){while(1){switch(_context56.prev=_context56.next){case 0:fetch=context.fetch,parse=context.parse;if(!image.uri){_context56.next=9;break;}uri=resolveUrl(image.uri,options);_context56.next=5;return fetch(uri);case 5:response=_context56.sent;_context56.next=8;return response.arrayBuffer();case 8:arrayBuffer=_context56.sent;case 9:if(Number.isFinite(image.bufferView)){array=getTypedArrayForBufferView(gltf.json,gltf.buffers,image.bufferView);arrayBuffer=sliceArrayBuffer(array.buffer,array.byteOffset,array.byteLength);}assert$1(arrayBuffer,'glTF image has no data');_context56.next=13;return parse(arrayBuffer,[ImageLoader,BasisLoader],{mimeType:image.mimeType,basis:options.basis||{format:selectSupportedBasisFormat()}},context);case 13:parsedImage=_context56.sent;if(parsedImage&&parsedImage[0]){parsedImage={compressed:true,mipmaps:false,width:parsedImage[0].width,height:parsedImage[0].height,data:parsedImage[0]};}gltf.images=gltf.images||[];gltf.images[index]=parsedImage;case 17:case"end":return _context56.stop();}}},_callee52);}));return _loadImage.apply(this,arguments);}var GLTFLoader={name:'glTF',id:'gltf',module:'gltf',version:VERSION$5,extensions:['gltf','glb'],mimeTypes:['model/gltf+json','model/gltf-binary'],text:true,binary:true,tests:['glTF'],parse:parse$1,options:{gltf:{normalize:true,loadBuffers:true,loadImages:true,decompressMeshes:true,postProcess:true},log:console},deprecatedOptions:{fetchImages:'gltf.loadImages',createImages:'gltf.loadImages',decompress:'gltf.decompressMeshes',postProcess:'gltf.postProcess',gltf:{decompress:'gltf.decompressMeshes'}}};function parse$1(_x99){return _parse$3.apply(this,arguments);}/**
|
|
25215
|
+
for(var _i509=0,len=plugins.length;_i509<len;_i509++){var plugin=plugins[_i509];plugin.destroy();}this.scene.destroy();}}]);return Viewer;}();function assert$5(condition,message){if(!condition){throw new Error(message||'loader assertion failed.');}}var isBrowser$4=Boolean((typeof process==="undefined"?"undefined":_typeof(process))!=='object'||String(process)!=='[object process]'||process.browser);var matches$1=typeof process!=='undefined'&&process.version&&/v([0-9]*)/.exec(process.version);matches$1&&parseFloat(matches$1[1])||0;var VERSION$9="3.2.6";function assert$4(condition,message){if(!condition){throw new Error(message||'loaders.gl assertion failed.');}}var globals$2={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document};var global_=globals$2.global||globals$2.self||globals$2.window||{};var isBrowser$3=(typeof process==="undefined"?"undefined":_typeof(process))!=='object'||String(process)!=='[object process]'||process.browser;var isWorker=typeof importScripts==='function';var isMobile=typeof window!=='undefined'&&typeof window.orientation!=='undefined';var matches=typeof process!=='undefined'&&process.version&&/v([0-9]*)/.exec(process.version);matches&&parseFloat(matches[1])||0;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;}var WorkerJob=/*#__PURE__*/function(){function WorkerJob(jobName,workerThread){var _this120=this;_classCallCheck(this,WorkerJob);_defineProperty(this,"name",void 0);_defineProperty(this,"workerThread",void 0);_defineProperty(this,"isRunning",true);_defineProperty(this,"result",void 0);_defineProperty(this,"_resolve",function(){});_defineProperty(this,"_reject",function(){});this.name=jobName;this.workerThread=workerThread;this.result=new Promise(function(resolve,reject){_this120._resolve=resolve;_this120._reject=reject;});}_createClass(WorkerJob,[{key:"postMessage",value:function postMessage(type,payload){this.workerThread.postMessage({source:'loaders.gl',type:type,payload:payload});}},{key:"done",value:function done(value){assert$4(this.isRunning);this.isRunning=false;this._resolve(value);}},{key:"error",value:function error(_error){assert$4(this.isRunning);this.isRunning=false;this._reject(_error);}}]);return WorkerJob;}();var Worker$1=/*#__PURE__*/_createClass(function Worker$1(){_classCallCheck(this,Worker$1);});var workerURLCache=new Map();function getLoadableWorkerURL(props){assert$4(props.source&&!props.url||!props.source&&props.url);var workerURL=workerURLCache.get(props.source||props.url);if(!workerURL){if(props.url){workerURL=getLoadableWorkerURLFromURL(props.url);workerURLCache.set(props.url,workerURL);}if(props.source){workerURL=getLoadableWorkerURLFromSource(props.source);workerURLCache.set(props.source,workerURL);}}assert$4(workerURL);return workerURL;}function getLoadableWorkerURLFromURL(url){if(!url.startsWith('http')){return url;}var workerSource=buildScriptSource(url);return getLoadableWorkerURLFromSource(workerSource);}function getLoadableWorkerURLFromSource(workerSource){var blob=new Blob([workerSource],{type:'application/javascript'});return URL.createObjectURL(blob);}function buildScriptSource(workerUrl){return"try {\n importScripts('".concat(workerUrl,"');\n} catch (error) {\n console.error(error);\n throw error;\n}");}function getTransferList(object){var recursive=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var transfers=arguments.length>2?arguments[2]:undefined;var transfersSet=transfers||new Set();if(!object);else if(isTransferable(object)){transfersSet.add(object);}else if(isTransferable(object.buffer)){transfersSet.add(object.buffer);}else if(ArrayBuffer.isView(object));else if(recursive&&_typeof(object)==='object'){for(var key in object){getTransferList(object[key],recursive,transfersSet);}}return transfers===undefined?Array.from(transfersSet):[];}function isTransferable(object){if(!object){return false;}if(object instanceof ArrayBuffer){return true;}if(typeof MessagePort!=='undefined'&&object instanceof MessagePort){return true;}if(typeof ImageBitmap!=='undefined'&&object instanceof ImageBitmap){return true;}if(typeof OffscreenCanvas!=='undefined'&&object instanceof OffscreenCanvas){return true;}return false;}var NOOP=function NOOP(){};var WorkerThread=/*#__PURE__*/function(){function WorkerThread(props){_classCallCheck(this,WorkerThread);_defineProperty(this,"name",void 0);_defineProperty(this,"source",void 0);_defineProperty(this,"url",void 0);_defineProperty(this,"terminated",false);_defineProperty(this,"worker",void 0);_defineProperty(this,"onMessage",void 0);_defineProperty(this,"onError",void 0);_defineProperty(this,"_loadableURL",'');var name=props.name,source=props.source,url=props.url;assert$4(source||url);this.name=name;this.source=source;this.url=url;this.onMessage=NOOP;this.onError=function(error){return console.log(error);};this.worker=isBrowser$3?this._createBrowserWorker():this._createNodeWorker();}_createClass(WorkerThread,[{key:"destroy",value:function destroy(){this.onMessage=NOOP;this.onError=NOOP;this.worker.terminate();this.terminated=true;}},{key:"isRunning",get:function get(){return Boolean(this.onMessage);}},{key:"postMessage",value:function postMessage(data,transferList){transferList=transferList||getTransferList(data);this.worker.postMessage(data,transferList);}},{key:"_getErrorFromErrorEvent",value:function _getErrorFromErrorEvent(event){var message='Failed to load ';message+="worker ".concat(this.name," from ").concat(this.url,". ");if(event.message){message+="".concat(event.message," in ");}if(event.lineno){message+=":".concat(event.lineno,":").concat(event.colno);}return new Error(message);}},{key:"_createBrowserWorker",value:function _createBrowserWorker(){var _this121=this;this._loadableURL=getLoadableWorkerURL({source:this.source,url:this.url});var worker=new Worker(this._loadableURL,{name:this.name});worker.onmessage=function(event){if(!event.data){_this121.onError(new Error('No data received'));}else{_this121.onMessage(event.data);}};worker.onerror=function(error){_this121.onError(_this121._getErrorFromErrorEvent(error));_this121.terminated=true;};worker.onmessageerror=function(event){return console.error(event);};return worker;}},{key:"_createNodeWorker",value:function _createNodeWorker(){var _this122=this;var worker;if(this.url){var absolute=this.url.includes(':/')||this.url.startsWith('/');var url=absolute?this.url:"./".concat(this.url);worker=new Worker$1(url,{eval:false});}else if(this.source){worker=new Worker$1(this.source,{eval:true});}else{throw new Error('no worker');}worker.on('message',function(data){_this122.onMessage(data);});worker.on('error',function(error){_this122.onError(error);});worker.on('exit',function(code){});return worker;}}],[{key:"isSupported",value:function isSupported(){return typeof Worker!=='undefined'&&isBrowser$3||_typeof(Worker$1)!==undefined;}}]);return WorkerThread;}();var WorkerPool=/*#__PURE__*/function(){function WorkerPool(props){_classCallCheck(this,WorkerPool);_defineProperty(this,"name",'unnamed');_defineProperty(this,"source",void 0);_defineProperty(this,"url",void 0);_defineProperty(this,"maxConcurrency",1);_defineProperty(this,"maxMobileConcurrency",1);_defineProperty(this,"onDebug",function(){});_defineProperty(this,"reuseWorkers",true);_defineProperty(this,"props",{});_defineProperty(this,"jobQueue",[]);_defineProperty(this,"idleQueue",[]);_defineProperty(this,"count",0);_defineProperty(this,"isDestroyed",false);this.source=props.source;this.url=props.url;this.setProps(props);}_createClass(WorkerPool,[{key:"destroy",value:function destroy(){this.idleQueue.forEach(function(worker){return worker.destroy();});this.isDestroyed=true;}},{key:"setProps",value:function setProps(props){this.props=_objectSpread(_objectSpread({},this.props),props);if(props.name!==undefined){this.name=props.name;}if(props.maxConcurrency!==undefined){this.maxConcurrency=props.maxConcurrency;}if(props.maxMobileConcurrency!==undefined){this.maxMobileConcurrency=props.maxMobileConcurrency;}if(props.reuseWorkers!==undefined){this.reuseWorkers=props.reuseWorkers;}if(props.onDebug!==undefined){this.onDebug=props.onDebug;}}},{key:"startJob",value:function(){var _startJob=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name){var _this123=this;var onMessage,onError,startPromise,_args2=arguments;return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:onMessage=_args2.length>1&&_args2[1]!==undefined?_args2[1]:function(job,type,data){return job.done(data);};onError=_args2.length>2&&_args2[2]!==undefined?_args2[2]:function(job,error){return job.error(error);};startPromise=new Promise(function(onStart){_this123.jobQueue.push({name:name,onMessage:onMessage,onError:onError,onStart:onStart});return _this123;});this._startQueuedJob();_context3.next=6;return startPromise;case 6:return _context3.abrupt("return",_context3.sent);case 7:case"end":return _context3.stop();}}},_callee2,this);}));function startJob(_x7){return _startJob.apply(this,arguments);}return startJob;}()},{key:"_startQueuedJob",value:function(){var _startQueuedJob2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var workerThread,queuedJob,job;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:if(this.jobQueue.length){_context4.next=2;break;}return _context4.abrupt("return");case 2:workerThread=this._getAvailableWorker();if(workerThread){_context4.next=5;break;}return _context4.abrupt("return");case 5:queuedJob=this.jobQueue.shift();if(!queuedJob){_context4.next=18;break;}this.onDebug({message:'Starting job',name:queuedJob.name,workerThread:workerThread,backlog:this.jobQueue.length});job=new WorkerJob(queuedJob.name,workerThread);workerThread.onMessage=function(data){return queuedJob.onMessage(job,data.type,data.payload);};workerThread.onError=function(error){return queuedJob.onError(job,error);};queuedJob.onStart(job);_context4.prev=12;_context4.next=15;return job.result;case 15:_context4.prev=15;this.returnWorkerToQueue(workerThread);return _context4.finish(15);case 18:case"end":return _context4.stop();}}},_callee3,this,[[12,,15,18]]);}));function _startQueuedJob(){return _startQueuedJob2.apply(this,arguments);}return _startQueuedJob;}()},{key:"returnWorkerToQueue",value:function returnWorkerToQueue(worker){var shouldDestroyWorker=this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency();if(shouldDestroyWorker){worker.destroy();this.count--;}else{this.idleQueue.push(worker);}if(!this.isDestroyed){this._startQueuedJob();}}},{key:"_getAvailableWorker",value:function _getAvailableWorker(){if(this.idleQueue.length>0){return this.idleQueue.shift()||null;}if(this.count<this._getMaxConcurrency()){this.count++;var _name5="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new WorkerThread({name:_name5,source:this.source,url:this.url});}return null;}},{key:"_getMaxConcurrency",value:function _getMaxConcurrency(){return isMobile?this.maxMobileConcurrency:this.maxConcurrency;}}],[{key:"isSupported",value:function isSupported(){return WorkerThread.isSupported();}}]);return WorkerPool;}();var DEFAULT_PROPS={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:true,onDebug:function onDebug(){}};var WorkerFarm=/*#__PURE__*/function(){function WorkerFarm(props){_classCallCheck(this,WorkerFarm);_defineProperty(this,"props",void 0);_defineProperty(this,"workerPools",new Map());this.props=_objectSpread({},DEFAULT_PROPS);this.setProps(props);this.workerPools=new Map();}_createClass(WorkerFarm,[{key:"destroy",value:function destroy(){var _iterator5=_createForOfIteratorHelper(this.workerPools.values()),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var workerPool=_step5.value;workerPool.destroy();}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}this.workerPools=new Map();}},{key:"setProps",value:function setProps(props){this.props=_objectSpread(_objectSpread({},this.props),props);var _iterator6=_createForOfIteratorHelper(this.workerPools.values()),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var workerPool=_step6.value;workerPool.setProps(this._getWorkerPoolProps());}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}}},{key:"getWorkerPool",value:function getWorkerPool(options){var name=options.name,source=options.source,url=options.url;var workerPool=this.workerPools.get(name);if(!workerPool){workerPool=new WorkerPool({name:name,source:source,url:url});workerPool.setProps(this._getWorkerPoolProps());this.workerPools.set(name,workerPool);}return workerPool;}},{key:"_getWorkerPoolProps",value:function _getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug};}}],[{key:"isSupported",value:function isSupported(){return WorkerThread.isSupported();}},{key:"getWorkerFarm",value:function getWorkerFarm(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};WorkerFarm._workerFarm=WorkerFarm._workerFarm||new WorkerFarm({});WorkerFarm._workerFarm.setProps(props);return WorkerFarm._workerFarm;}}]);return WorkerFarm;}();_defineProperty(WorkerFarm,"_workerFarm",void 0);var NPM_TAG='latest';function getWorkerURL(worker){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var workerOptions=options[worker.id]||{};var workerFile="".concat(worker.id,"-worker.js");var url=workerOptions.workerUrl;if(!url&&worker.id==='compression'){url=options.workerUrl;}if(options._workerType==='test'){url="modules/".concat(worker.module,"/dist/").concat(workerFile);}if(!url){var version=worker.version;if(version==='latest'){version=NPM_TAG;}var versionTag=version?"@".concat(version):'';url="https://unpkg.com/@loaders.gl/".concat(worker.module).concat(versionTag,"/dist/").concat(workerFile);}assert$4(url);return url;}function validateWorkerVersion(worker){var coreVersion=arguments.length>1&&arguments[1]!==undefined?arguments[1]:VERSION$9;assert$4(worker,'no worker provided');var workerVersion=worker.version;if(!coreVersion||!workerVersion){return false;}return true;}var ChildProcessProxy={};var node=/*#__PURE__*/Object.freeze({__proto__:null,'default':ChildProcessProxy});var VERSION$8="3.2.6";var loadLibraryPromises={};function loadLibrary(_x8){return _loadLibrary.apply(this,arguments);}function _loadLibrary(){_loadLibrary=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(libraryUrl){var moduleName,options,_args6=arguments;return _regeneratorRuntime().wrap(function _callee8$(_context12){while(1){switch(_context12.prev=_context12.next){case 0:moduleName=_args6.length>1&&_args6[1]!==undefined?_args6[1]:null;options=_args6.length>2&&_args6[2]!==undefined?_args6[2]:{};if(moduleName){libraryUrl=getLibraryUrl(libraryUrl,moduleName,options);}loadLibraryPromises[libraryUrl]=loadLibraryPromises[libraryUrl]||loadLibraryFromFile(libraryUrl);_context12.next=6;return loadLibraryPromises[libraryUrl];case 6:return _context12.abrupt("return",_context12.sent);case 7:case"end":return _context12.stop();}}},_callee8);}));return _loadLibrary.apply(this,arguments);}function getLibraryUrl(library,moduleName,options){if(library.startsWith('http')){return library;}var modules=options.modules||{};if(modules[library]){return modules[library];}if(!isBrowser$3){return"modules/".concat(moduleName,"/dist/libs/").concat(library);}if(options.CDN){assert$4(options.CDN.startsWith('http'));return"".concat(options.CDN,"/").concat(moduleName,"@").concat(VERSION$8,"/dist/libs/").concat(library);}if(isWorker){return"../src/libs/".concat(library);}return"modules/".concat(moduleName,"/src/libs/").concat(library);}function loadLibraryFromFile(_x9){return _loadLibraryFromFile.apply(this,arguments);}function _loadLibraryFromFile(){_loadLibraryFromFile=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(libraryUrl){var _response,response,scriptSource;return _regeneratorRuntime().wrap(function _callee9$(_context13){while(1){switch(_context13.prev=_context13.next){case 0:if(!libraryUrl.endsWith('wasm')){_context13.next=7;break;}_context13.next=3;return fetch(libraryUrl);case 3:_response=_context13.sent;_context13.next=6;return _response.arrayBuffer();case 6:return _context13.abrupt("return",_context13.sent);case 7:if(isBrowser$3){_context13.next=20;break;}_context13.prev=8;_context13.t0=node&&undefined;if(!_context13.t0){_context13.next=14;break;}_context13.next=13;return undefined(libraryUrl);case 13:_context13.t0=_context13.sent;case 14:return _context13.abrupt("return",_context13.t0);case 17:_context13.prev=17;_context13.t1=_context13["catch"](8);return _context13.abrupt("return",null);case 20:if(!isWorker){_context13.next=22;break;}return _context13.abrupt("return",importScripts(libraryUrl));case 22:_context13.next=24;return fetch(libraryUrl);case 24:response=_context13.sent;_context13.next=27;return response.text();case 27:scriptSource=_context13.sent;return _context13.abrupt("return",loadLibraryFromString(scriptSource,libraryUrl));case 29:case"end":return _context13.stop();}}},_callee9,null,[[8,17]]);}));return _loadLibraryFromFile.apply(this,arguments);}function loadLibraryFromString(scriptSource,id){if(!isBrowser$3){return undefined&&undefined(scriptSource,id);}if(isWorker){eval.call(global_,scriptSource);return null;}var script=document.createElement('script');script.id=id;try{script.appendChild(document.createTextNode(scriptSource));}catch(e){script.text=scriptSource;}document.body.appendChild(script);return null;}function canParseWithWorker(loader,options){if(!WorkerFarm.isSupported()){return false;}if(!isBrowser$3&&!(options!==null&&options!==void 0&&options._nodeWorkers)){return false;}return loader.worker&&(options===null||options===void 0?void 0:options.worker);}function parseWithWorker(_x10,_x11,_x12,_x13,_x14){return _parseWithWorker.apply(this,arguments);}function _parseWithWorker(){_parseWithWorker=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(loader,data,options,context,parseOnMainThread){var name,url,workerFarm,workerPool,job,result;return _regeneratorRuntime().wrap(function _callee10$(_context14){while(1){switch(_context14.prev=_context14.next){case 0:name=loader.id;url=getWorkerURL(loader,options);workerFarm=WorkerFarm.getWorkerFarm(options);workerPool=workerFarm.getWorkerPool({name:name,url:url});options=JSON.parse(JSON.stringify(options));context=JSON.parse(JSON.stringify(context||{}));_context14.next=8;return workerPool.startJob('process-on-worker',onMessage.bind(null,parseOnMainThread));case 8:job=_context14.sent;job.postMessage('process',{input:data,options:options,context:context});_context14.next=12;return job.result;case 12:result=_context14.sent;_context14.next=15;return result.result;case 15:return _context14.abrupt("return",_context14.sent);case 16:case"end":return _context14.stop();}}},_callee10);}));return _parseWithWorker.apply(this,arguments);}function onMessage(_x15,_x16,_x17,_x18){return _onMessage2.apply(this,arguments);}function _onMessage2(){_onMessage2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(parseOnMainThread,job,type,payload){var id,input,options,result,message;return _regeneratorRuntime().wrap(function _callee11$(_context15){while(1){switch(_context15.prev=_context15.next){case 0:_context15.t0=type;_context15.next=_context15.t0==='done'?3:_context15.t0==='error'?5:_context15.t0==='process'?7:20;break;case 3:job.done(payload);return _context15.abrupt("break",21);case 5:job.error(new Error(payload.error));return _context15.abrupt("break",21);case 7:id=payload.id,input=payload.input,options=payload.options;_context15.prev=8;_context15.next=11;return parseOnMainThread(input,options);case 11:result=_context15.sent;job.postMessage('done',{id:id,result:result});_context15.next=19;break;case 15:_context15.prev=15;_context15.t1=_context15["catch"](8);message=_context15.t1 instanceof Error?_context15.t1.message:'unknown error';job.postMessage('error',{id:id,error:message});case 19:return _context15.abrupt("break",21);case 20:console.warn("parse-with-worker unknown message ".concat(type));case 21:case"end":return _context15.stop();}}},_callee11,null,[[8,15]]);}));return _onMessage2.apply(this,arguments);}function getFirstCharacters$1(data){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5;if(typeof data==='string'){return data.slice(0,length);}else if(ArrayBuffer.isView(data)){return getMagicString$2(data.buffer,data.byteOffset,length);}else if(data instanceof ArrayBuffer){var byteOffset=0;return getMagicString$2(data,byteOffset,length);}return'';}function getMagicString$2(arrayBuffer,byteOffset,length){if(arrayBuffer.byteLength<=byteOffset+length){return'';}var dataView=new DataView(arrayBuffer);var magic='';for(var _i510=0;_i510<length;_i510++){magic+=String.fromCharCode(dataView.getUint8(byteOffset+_i510));}return magic;}function parseJSON(string){try{return JSON.parse(string);}catch(_){throw new Error("Failed to parse JSON from data starting with \"".concat(getFirstCharacters$1(string),"\""));}}function isBuffer$1(value){return value&&_typeof(value)==='object'&&value.isBuffer;}function bufferToArrayBuffer(buffer){if(isBuffer$1(buffer)){var typedArray=new Uint8Array(buffer.buffer,buffer.byteOffset,buffer.length);return typedArray.slice().buffer;}return buffer;}function toArrayBuffer(data){if(isBuffer$1(data)){return bufferToArrayBuffer(data);}if(data instanceof ArrayBuffer){return data;}if(ArrayBuffer.isView(data)){if(data.byteOffset===0&&data.byteLength===data.buffer.byteLength){return data.buffer;}return data.buffer.slice(data.byteOffset,data.byteOffset+data.byteLength);}if(typeof data==='string'){var text=data;var uint8Array=new TextEncoder().encode(text);return uint8Array.buffer;}if(data&&_typeof(data)==='object'&&data._toArrayBuffer){return data._toArrayBuffer();}throw new Error('toArrayBuffer');}function compareArrayBuffers(arrayBuffer1,arrayBuffer2,byteLength){byteLength=byteLength||arrayBuffer1.byteLength;if(arrayBuffer1.byteLength<byteLength||arrayBuffer2.byteLength<byteLength){return false;}var array1=new Uint8Array(arrayBuffer1);var array2=new Uint8Array(arrayBuffer2);for(var _i511=0;_i511<array1.length;++_i511){if(array1[_i511]!==array2[_i511]){return false;}}return true;}function concatenateArrayBuffers(){for(var _len101=arguments.length,sources=new Array(_len101),_key6=0;_key6<_len101;_key6++){sources[_key6]=arguments[_key6];}var sourceArrays=sources.map(function(source2){return source2 instanceof ArrayBuffer?new Uint8Array(source2):source2;});var byteLength=sourceArrays.reduce(function(length,typedArray){return length+typedArray.byteLength;},0);var result=new Uint8Array(byteLength);var offset=0;var _iterator7=_createForOfIteratorHelper(sourceArrays),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var sourceArray=_step7.value;result.set(sourceArray,offset);offset+=sourceArray.byteLength;}}catch(err){_iterator7.e(err);}finally{_iterator7.f();}return result.buffer;}function sliceArrayBuffer(arrayBuffer,byteOffset,byteLength){var subArray=byteLength!==undefined?new Uint8Array(arrayBuffer).subarray(byteOffset,byteOffset+byteLength):new Uint8Array(arrayBuffer).subarray(byteOffset);var arrayCopy=new Uint8Array(subArray);return arrayCopy.buffer;}function padToNBytes(byteLength,padding){assert$5(byteLength>=0);assert$5(padding>0);return byteLength+(padding-1)&~(padding-1);}function copyToArray(source,target,targetOffset){var sourceArray;if(source instanceof ArrayBuffer){sourceArray=new Uint8Array(source);}else{var srcByteOffset=source.byteOffset;var srcByteLength=source.byteLength;sourceArray=new Uint8Array(source.buffer||source.arrayBuffer,srcByteOffset,srcByteLength);}target.set(sourceArray,targetOffset);return targetOffset+padToNBytes(sourceArray.byteLength,4);}function concatenateArrayBuffersAsync(_x19){return _concatenateArrayBuffersAsync.apply(this,arguments);}function _concatenateArrayBuffersAsync(){_concatenateArrayBuffersAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(asyncIterator){var arrayBuffers,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,chunk;return _regeneratorRuntime().wrap(function _callee12$(_context16){while(1){switch(_context16.prev=_context16.next){case 0:arrayBuffers=[];_iteratorAbruptCompletion=false;_didIteratorError=false;_context16.prev=3;_iterator=_asyncIterator(asyncIterator);case 5:_context16.next=7;return _iterator.next();case 7:if(!(_iteratorAbruptCompletion=!(_step=_context16.sent).done)){_context16.next=13;break;}chunk=_step.value;arrayBuffers.push(chunk);case 10:_iteratorAbruptCompletion=false;_context16.next=5;break;case 13:_context16.next=19;break;case 15:_context16.prev=15;_context16.t0=_context16["catch"](3);_didIteratorError=true;_iteratorError=_context16.t0;case 19:_context16.prev=19;_context16.prev=20;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context16.next=24;break;}_context16.next=24;return _iterator["return"]();case 24:_context16.prev=24;if(!_didIteratorError){_context16.next=27;break;}throw _iteratorError;case 27:return _context16.finish(24);case 28:return _context16.finish(19);case 29:return _context16.abrupt("return",concatenateArrayBuffers.apply(void 0,arrayBuffers));case 30:case"end":return _context16.stop();}}},_callee12,null,[[3,15,19,29],[20,,24,28]]);}));return _concatenateArrayBuffersAsync.apply(this,arguments);}var pathPrefix='';var fileAliases={};function resolvePath(filename){for(var alias in fileAliases){if(filename.startsWith(alias)){var replacement=fileAliases[alias];filename=filename.replace(alias,replacement);}}if(!filename.startsWith('http://')&&!filename.startsWith('https://')){filename="".concat(pathPrefix).concat(filename);}return filename;}function filename(url){var slashIndex=url&&url.lastIndexOf('/');return slashIndex>=0?url.substr(slashIndex+1):'';}var isBoolean=function isBoolean(x){return typeof x==='boolean';};var isFunction=function isFunction(x){return typeof x==='function';};var isObject=function isObject(x){return x!==null&&_typeof(x)==='object';};var isPureObject=function isPureObject(x){return isObject(x)&&x.constructor==={}.constructor;};var isIterable=function isIterable(x){return x&&typeof x[Symbol.iterator]==='function';};var isAsyncIterable=function isAsyncIterable(x){return x&&typeof x[Symbol.asyncIterator]==='function';};var isResponse=function isResponse(x){return typeof Response!=='undefined'&&x instanceof Response||x&&x.arrayBuffer&&x.text&&x.json;};var isBlob=function isBlob(x){return typeof Blob!=='undefined'&&x instanceof Blob;};var isBuffer=function isBuffer(x){return x&&_typeof(x)==='object'&&x.isBuffer;};var isReadableDOMStream=function isReadableDOMStream(x){return typeof ReadableStream!=='undefined'&&x instanceof ReadableStream||isObject(x)&&isFunction(x.tee)&&isFunction(x.cancel)&&isFunction(x.getReader);};var isReadableNodeStream=function isReadableNodeStream(x){return isObject(x)&&isFunction(x.read)&&isFunction(x.pipe)&&isBoolean(x.readable);};var isReadableStream=function isReadableStream(x){return isReadableDOMStream(x)||isReadableNodeStream(x);};var DATA_URL_PATTERN=/^data:([-\w.]+\/[-\w.+]+)(;|,)/;var MIME_TYPE_PATTERN=/^([-\w.]+\/[-\w.+]+)/;function parseMIMEType(mimeString){var matches=MIME_TYPE_PATTERN.exec(mimeString);if(matches){return matches[1];}return mimeString;}function parseMIMETypeFromURL(url){var matches=DATA_URL_PATTERN.exec(url);if(matches){return matches[1];}return'';}var QUERY_STRING_PATTERN=/\?.*/;function getResourceUrlAndType(resource){if(isResponse(resource)){var url=stripQueryString(resource.url||'');var contentTypeHeader=resource.headers.get('content-type')||'';return{url:url,type:parseMIMEType(contentTypeHeader)||parseMIMETypeFromURL(url)};}if(isBlob(resource)){return{url:stripQueryString(resource.name||''),type:resource.type||''};}if(typeof resource==='string'){return{url:stripQueryString(resource),type:parseMIMETypeFromURL(resource)};}return{url:'',type:''};}function getResourceContentLength(resource){if(isResponse(resource)){return resource.headers['content-length']||-1;}if(isBlob(resource)){return resource.size;}if(typeof resource==='string'){return resource.length;}if(resource instanceof ArrayBuffer){return resource.byteLength;}if(ArrayBuffer.isView(resource)){return resource.byteLength;}return-1;}function stripQueryString(url){return url.replace(QUERY_STRING_PATTERN,'');}function makeResponse(_x20){return _makeResponse.apply(this,arguments);}function _makeResponse(){_makeResponse=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(resource){var headers,contentLength,_getResourceUrlAndTyp3,url,type,initialDataUrl,response;return _regeneratorRuntime().wrap(function _callee13$(_context17){while(1){switch(_context17.prev=_context17.next){case 0:if(!isResponse(resource)){_context17.next=2;break;}return _context17.abrupt("return",resource);case 2:headers={};contentLength=getResourceContentLength(resource);if(contentLength>=0){headers['content-length']=String(contentLength);}_getResourceUrlAndTyp3=getResourceUrlAndType(resource),url=_getResourceUrlAndTyp3.url,type=_getResourceUrlAndTyp3.type;if(type){headers['content-type']=type;}_context17.next=9;return getInitialDataUrl(resource);case 9:initialDataUrl=_context17.sent;if(initialDataUrl){headers['x-first-bytes']=initialDataUrl;}if(typeof resource==='string'){resource=new TextEncoder().encode(resource);}response=new Response(resource,{headers:headers});Object.defineProperty(response,'url',{value:url});return _context17.abrupt("return",response);case 15:case"end":return _context17.stop();}}},_callee13);}));return _makeResponse.apply(this,arguments);}function checkResponse(_x21){return _checkResponse.apply(this,arguments);}function _checkResponse(){_checkResponse=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(response){var message;return _regeneratorRuntime().wrap(function _callee14$(_context18){while(1){switch(_context18.prev=_context18.next){case 0:if(response.ok){_context18.next=5;break;}_context18.next=3;return getResponseError(response);case 3:message=_context18.sent;throw new Error(message);case 5:case"end":return _context18.stop();}}},_callee14);}));return _checkResponse.apply(this,arguments);}function getResponseError(_x22){return _getResponseError.apply(this,arguments);}function _getResponseError(){_getResponseError=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(response){var message,contentType,text;return _regeneratorRuntime().wrap(function _callee15$(_context19){while(1){switch(_context19.prev=_context19.next){case 0:message="Failed to fetch resource ".concat(response.url," (").concat(response.status,"): ");_context19.prev=1;contentType=response.headers.get('Content-Type');text=response.statusText;if(!contentType.includes('application/json')){_context19.next=11;break;}_context19.t0=text;_context19.t1=" ";_context19.next=9;return response.text();case 9:_context19.t2=_context19.sent;text=_context19.t0+=_context19.t1.concat.call(_context19.t1,_context19.t2);case 11:message+=text;message=message.length>60?"".concat(message.slice(0,60),"..."):message;_context19.next=17;break;case 15:_context19.prev=15;_context19.t3=_context19["catch"](1);case 17:return _context19.abrupt("return",message);case 18:case"end":return _context19.stop();}}},_callee15,null,[[1,15]]);}));return _getResponseError.apply(this,arguments);}function getInitialDataUrl(_x23){return _getInitialDataUrl.apply(this,arguments);}function _getInitialDataUrl(){_getInitialDataUrl=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(resource){var INITIAL_DATA_LENGTH,blobSlice,slice,_base;return _regeneratorRuntime().wrap(function _callee16$(_context20){while(1){switch(_context20.prev=_context20.next){case 0:INITIAL_DATA_LENGTH=5;if(!(typeof resource==='string')){_context20.next=3;break;}return _context20.abrupt("return","data:,".concat(resource.slice(0,INITIAL_DATA_LENGTH)));case 3:if(!(resource instanceof Blob)){_context20.next=8;break;}blobSlice=resource.slice(0,5);_context20.next=7;return new Promise(function(resolve){var reader=new FileReader();reader.onload=function(event){var _event$target;return resolve(event===null||event===void 0?void 0:(_event$target=event.target)===null||_event$target===void 0?void 0:_event$target.result);};reader.readAsDataURL(blobSlice);});case 7:return _context20.abrupt("return",_context20.sent);case 8:if(!(resource instanceof ArrayBuffer)){_context20.next=12;break;}slice=resource.slice(0,INITIAL_DATA_LENGTH);_base=arrayBufferToBase64(slice);return _context20.abrupt("return","data:base64,".concat(_base));case 12:return _context20.abrupt("return",null);case 13:case"end":return _context20.stop();}}},_callee16);}));return _getInitialDataUrl.apply(this,arguments);}function arrayBufferToBase64(buffer){var binary='';var bytes=new Uint8Array(buffer);for(var _i512=0;_i512<bytes.byteLength;_i512++){binary+=String.fromCharCode(bytes[_i512]);}return btoa(binary);}function fetchFile(_x24,_x25){return _fetchFile.apply(this,arguments);}function _fetchFile(){_fetchFile=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(url,options){var fetchOptions;return _regeneratorRuntime().wrap(function _callee17$(_context21){while(1){switch(_context21.prev=_context21.next){case 0:if(!(typeof url==='string')){_context21.next=7;break;}url=resolvePath(url);fetchOptions=options;if(options!==null&&options!==void 0&&options.fetch&&typeof(options===null||options===void 0?void 0:options.fetch)!=='function'){fetchOptions=options.fetch;}_context21.next=6;return fetch(url,fetchOptions);case 6:return _context21.abrupt("return",_context21.sent);case 7:_context21.next=9;return makeResponse(url);case 9:return _context21.abrupt("return",_context21.sent);case 10:case"end":return _context21.stop();}}},_callee17);}));return _fetchFile.apply(this,arguments);}function isElectron$1(mockUserAgent){if(typeof window!=='undefined'&&_typeof(window.process)==='object'&&window.process.type==='renderer'){return true;}if(typeof process!=='undefined'&&_typeof(process.versions)==='object'&&Boolean(process.versions.electron)){return true;}var realUserAgent=(typeof navigator==="undefined"?"undefined":_typeof(navigator))==='object'&&typeof navigator.userAgent==='string'&&navigator.userAgent;var userAgent=mockUserAgent||realUserAgent;if(userAgent&&userAgent.indexOf('Electron')>=0){return true;}return false;}function isBrowser$2(){var isNode=(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&String(process)==='[object process]'&&!process.browser;return!isNode||isElectron$1();}var globals$1={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document,process:(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&process};var window_$1=globals$1.window||globals$1.self||globals$1.global;var process_$1=globals$1.process||{};var VERSION$7=typeof __VERSION__!=='undefined'?__VERSION__:'untranspiled source';var isBrowser$1=isBrowser$2();function getStorage$1(type){try{var storage=window[type];var x='__storage_test__';storage.setItem(x,x);storage.removeItem(x);return storage;}catch(e){return null;}}var LocalStorage$1=/*#__PURE__*/function(){function LocalStorage$1(id,defaultSettings){var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'sessionStorage';_classCallCheck(this,LocalStorage$1);this.storage=getStorage$1(type);this.id=id;this.config={};Object.assign(this.config,defaultSettings);this._loadConfiguration();}_createClass(LocalStorage$1,[{key:"getConfiguration",value:function getConfiguration(){return this.config;}},{key:"setConfiguration",value:function setConfiguration(configuration){this.config={};return this.updateConfiguration(configuration);}},{key:"updateConfiguration",value:function updateConfiguration(configuration){Object.assign(this.config,configuration);if(this.storage){var serialized=JSON.stringify(this.config);this.storage.setItem(this.id,serialized);}return this;}},{key:"_loadConfiguration",value:function _loadConfiguration(){var configuration={};if(this.storage){var serializedConfiguration=this.storage.getItem(this.id);configuration=serializedConfiguration?JSON.parse(serializedConfiguration):{};}Object.assign(this.config,configuration);return this;}}]);return LocalStorage$1;}();function formatTime$1(ms){var formatted;if(ms<10){formatted="".concat(ms.toFixed(2),"ms");}else if(ms<100){formatted="".concat(ms.toFixed(1),"ms");}else if(ms<1000){formatted="".concat(ms.toFixed(0),"ms");}else{formatted="".concat((ms/1000).toFixed(2),"s");}return formatted;}function leftPad$1(string){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:8;var padLength=Math.max(length-string.length,0);return"".concat(' '.repeat(padLength)).concat(string);}function formatImage$1(image,message,scale){var maxWidth=arguments.length>3&&arguments[3]!==undefined?arguments[3]:600;var imageUrl=image.src.replace(/\(/g,'%28').replace(/\)/g,'%29');if(image.width>maxWidth){scale=Math.min(scale,maxWidth/image.width);}var width=image.width*scale;var height=image.height*scale;var style=['font-size:1px;',"padding:".concat(Math.floor(height/2),"px ").concat(Math.floor(width/2),"px;"),"line-height:".concat(height,"px;"),"background:url(".concat(imageUrl,");"),"background-size:".concat(width,"px ").concat(height,"px;"),'color:transparent;'].join('');return["".concat(message," %c+"),style];}var COLOR$1={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function getColor$1(color){return typeof color==='string'?COLOR$1[color.toUpperCase()]||COLOR$1.WHITE:color;}function addColor$1(string,color,background){if(!isBrowser$1&&typeof string==='string'){if(color){color=getColor$1(color);string="\x1B[".concat(color,"m").concat(string,"\x1B[39m");}if(background){color=getColor$1(background);string="\x1B[".concat(background+10,"m").concat(string,"\x1B[49m");}}return string;}function autobind$1(obj){var predefined=arguments.length>1&&arguments[1]!==undefined?arguments[1]:['constructor'];var proto=Object.getPrototypeOf(obj);var propNames=Object.getOwnPropertyNames(proto);var _iterator8=_createForOfIteratorHelper(propNames),_step8;try{var _loop4=function _loop4(){var key=_step8.value;if(typeof obj[key]==='function'){if(!predefined.find(function(name){return key===name;})){obj[key]=obj[key].bind(obj);}}};for(_iterator8.s();!(_step8=_iterator8.n()).done;){_loop4();}}catch(err){_iterator8.e(err);}finally{_iterator8.f();}}function assert$3(condition,message){if(!condition){throw new Error(message||'Assertion failed');}}function getHiResTimestamp$1(){var timestamp;if(isBrowser$1&&window_$1.performance){timestamp=window_$1.performance.now();}else if(process_$1.hrtime){var timeParts=process_$1.hrtime();timestamp=timeParts[0]*1000+timeParts[1]/1e6;}else{timestamp=Date.now();}return timestamp;}var originalConsole$1={debug:isBrowser$1?console.debug||console.log:console.log,log:console.log,info:console.info,warn:console.warn,error:console.error};var DEFAULT_SETTINGS$1={enabled:true,level:0};function noop$1(){}var cache$1={};var ONCE$1={once:true};function getTableHeader$1(table){for(var key in table){for(var title in table[key]){return title||'untitled';}}return'empty';}var Log$1=/*#__PURE__*/function(){function Log$1(){var _ref18=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{id:''},id=_ref18.id;_classCallCheck(this,Log$1);this.id=id;this.VERSION=VERSION$7;this._startTs=getHiResTimestamp$1();this._deltaTs=getHiResTimestamp$1();this.LOG_THROTTLE_TIMEOUT=0;this._storage=new LocalStorage$1("__probe-".concat(this.id,"__"),DEFAULT_SETTINGS$1);this.userData={};this.timeStamp("".concat(this.id," started"));autobind$1(this);Object.seal(this);}_createClass(Log$1,[{key:"level",get:function get(){return this.getLevel();},set:function set(newLevel){this.setLevel(newLevel);}},{key:"isEnabled",value:function isEnabled(){return this._storage.config.enabled;}},{key:"getLevel",value:function getLevel(){return this._storage.config.level;}},{key:"getTotal",value:function getTotal(){return Number((getHiResTimestamp$1()-this._startTs).toPrecision(10));}},{key:"getDelta",value:function getDelta(){return Number((getHiResTimestamp$1()-this._deltaTs).toPrecision(10));}},{key:"priority",get:function get(){return this.level;},set:function set(newPriority){this.level=newPriority;}},{key:"getPriority",value:function getPriority(){return this.level;}},{key:"enable",value:function enable(){var enabled=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;this._storage.updateConfiguration({enabled:enabled});return this;}},{key:"setLevel",value:function setLevel(level){this._storage.updateConfiguration({level:level});return this;}},{key:"assert",value:function assert(condition,message){assert$3(condition,message);}},{key:"warn",value:function warn(message){return this._getLogFunction(0,message,originalConsole$1.warn,arguments,ONCE$1);}},{key:"error",value:function error(message){return this._getLogFunction(0,message,originalConsole$1.error,arguments);}},{key:"deprecated",value:function deprecated(oldUsage,newUsage){return this.warn("`".concat(oldUsage,"` is deprecated and will be removed in a later version. Use `").concat(newUsage,"` instead"));}},{key:"removed",value:function removed(oldUsage,newUsage){return this.error("`".concat(oldUsage,"` has been removed. Use `").concat(newUsage,"` instead"));}},{key:"probe",value:function probe(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.log,arguments,{time:true,once:true});}},{key:"log",value:function log(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.debug,arguments);}},{key:"info",value:function info(logLevel,message){return this._getLogFunction(logLevel,message,console.info,arguments);}},{key:"once",value:function once(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole$1.debug||originalConsole$1.info,arguments,ONCE$1);}},{key:"table",value:function table(logLevel,_table,columns){if(_table){return this._getLogFunction(logLevel,_table,console.table||noop$1,columns&&[columns],{tag:getTableHeader$1(_table)});}return noop$1;}},{key:"image",value:function(_image6){function image(_x26){return _image6.apply(this,arguments);}image.toString=function(){return _image6.toString();};return image;}(function(_ref19){var logLevel=_ref19.logLevel,priority=_ref19.priority,image=_ref19.image,_ref19$message=_ref19.message,message=_ref19$message===void 0?'':_ref19$message,_ref19$scale=_ref19.scale,scale=_ref19$scale===void 0?1:_ref19$scale;if(!this._shouldLog(logLevel||priority)){return noop$1;}return isBrowser$1?logImageInBrowser$1({image:image,message:message,scale:scale}):logImageInNode$1({image:image,message:message,scale:scale});})},{key:"settings",value:function settings(){if(console.table){console.table(this._storage.config);}else{console.log(this._storage.config);}}},{key:"get",value:function get(setting){return this._storage.config[setting];}},{key:"set",value:function set(setting,value){this._storage.updateConfiguration(_defineProperty2({},setting,value));}},{key:"time",value:function time(logLevel,message){return this._getLogFunction(logLevel,message,console.time?console.time:console.info);}},{key:"timeEnd",value:function timeEnd(logLevel,message){return this._getLogFunction(logLevel,message,console.timeEnd?console.timeEnd:console.info);}},{key:"timeStamp",value:function timeStamp(logLevel,message){return this._getLogFunction(logLevel,message,console.timeStamp||noop$1);}},{key:"group",value:function group(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{collapsed:false};opts=normalizeArguments$1({logLevel:logLevel,message:message,opts:opts});var _opts=opts,collapsed=_opts.collapsed;opts.method=(collapsed?console.groupCollapsed:console.group)||console.info;return this._getLogFunction(opts);}},{key:"groupCollapsed",value:function groupCollapsed(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return this.group(logLevel,message,Object.assign({},opts,{collapsed:true}));}},{key:"groupEnd",value:function groupEnd(logLevel){return this._getLogFunction(logLevel,'',console.groupEnd||noop$1);}},{key:"withGroup",value:function withGroup(logLevel,message,func){this.group(logLevel,message)();try{func();}finally{this.groupEnd(logLevel)();}}},{key:"trace",value:function trace(){if(console.trace){console.trace();}}},{key:"_shouldLog",value:function _shouldLog(logLevel){return this.isEnabled()&&this.getLevel()>=normalizeLogLevel$1(logLevel);}},{key:"_getLogFunction",value:function _getLogFunction(logLevel,message,method){var args=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];var opts=arguments.length>4?arguments[4]:undefined;if(this._shouldLog(logLevel)){var _method;opts=normalizeArguments$1({logLevel:logLevel,message:message,args:args,opts:opts});method=method||opts.method;assert$3(method);opts.total=this.getTotal();opts.delta=this.getDelta();this._deltaTs=getHiResTimestamp$1();var tag=opts.tag||opts.message;if(opts.once){if(!cache$1[tag]){cache$1[tag]=getHiResTimestamp$1();}else{return noop$1;}}message=decorateMessage$1(this.id,opts.message,opts);return(_method=method).bind.apply(_method,[console,message].concat(_toConsumableArray(opts.args)));}return noop$1;}}]);return Log$1;}();Log$1.VERSION=VERSION$7;function normalizeLogLevel$1(logLevel){if(!logLevel){return 0;}var resolvedLevel;switch(_typeof(logLevel)){case'number':resolvedLevel=logLevel;break;case'object':resolvedLevel=logLevel.logLevel||logLevel.priority||0;break;default:return 0;}assert$3(Number.isFinite(resolvedLevel)&&resolvedLevel>=0);return resolvedLevel;}function normalizeArguments$1(opts){var logLevel=opts.logLevel,message=opts.message;opts.logLevel=normalizeLogLevel$1(logLevel);var args=opts.args?Array.from(opts.args):[];while(args.length&&args.shift()!==message){}opts.args=args;switch(_typeof(logLevel)){case'string':case'function':if(message!==undefined){args.unshift(message);}opts.message=logLevel;break;case'object':Object.assign(opts,logLevel);break;}if(typeof opts.message==='function'){opts.message=opts.message();}var messageType=_typeof(opts.message);assert$3(messageType==='string'||messageType==='object');return Object.assign(opts,opts.opts);}function decorateMessage$1(id,message,opts){if(typeof message==='string'){var _time=opts.time?leftPad$1(formatTime$1(opts.total)):'';message=opts.time?"".concat(id,": ").concat(_time," ").concat(message):"".concat(id,": ").concat(message);message=addColor$1(message,opts.color,opts.background);}return message;}function logImageInNode$1(_ref20){var image=_ref20.image,_ref20$message=_ref20.message,message=_ref20$message===void 0?'':_ref20$message,_ref20$scale=_ref20.scale,scale=_ref20$scale===void 0?1:_ref20$scale;var asciify=null;try{asciify=module.require('asciify-image');}catch(error){}if(asciify){return function(){return asciify(image,{fit:'box',width:"".concat(Math.round(80*scale),"%")}).then(function(data){return console.log(data);});};}return noop$1;}function logImageInBrowser$1(_ref21){var image=_ref21.image,_ref21$message=_ref21.message,message=_ref21$message===void 0?'':_ref21$message,_ref21$scale=_ref21.scale,scale=_ref21$scale===void 0?1:_ref21$scale;if(typeof image==='string'){var img=new Image();img.onload=function(){var _console;var args=formatImage$1(img,message,scale);(_console=console).log.apply(_console,_toConsumableArray(args));};img.src=image;return noop$1;}var element=image.nodeName||'';if(element.toLowerCase()==='img'){var _console2;(_console2=console).log.apply(_console2,_toConsumableArray(formatImage$1(image,message,scale)));return noop$1;}if(element.toLowerCase()==='canvas'){var _img=new Image();_img.onload=function(){var _console3;return(_console3=console).log.apply(_console3,_toConsumableArray(formatImage$1(_img,message,scale)));};_img.src=image.toDataURL();return noop$1;}return noop$1;}var probeLog=new Log$1({id:'loaders.gl'});var NullLog=/*#__PURE__*/function(){function NullLog(){_classCallCheck(this,NullLog);}_createClass(NullLog,[{key:"log",value:function log(){return function(){};}},{key:"info",value:function info(){return function(){};}},{key:"warn",value:function warn(){return function(){};}},{key:"error",value:function error(){return function(){};}}]);return NullLog;}();var ConsoleLog=/*#__PURE__*/function(){function ConsoleLog(){_classCallCheck(this,ConsoleLog);_defineProperty(this,"console",void 0);this.console=console;}_createClass(ConsoleLog,[{key:"log",value:function log(){var _this$console$log;for(var _len102=arguments.length,args=new Array(_len102),_key7=0;_key7<_len102;_key7++){args[_key7]=arguments[_key7];}return(_this$console$log=this.console.log).bind.apply(_this$console$log,[this.console].concat(args));}},{key:"info",value:function info(){var _this$console$info;for(var _len103=arguments.length,args=new Array(_len103),_key8=0;_key8<_len103;_key8++){args[_key8]=arguments[_key8];}return(_this$console$info=this.console.info).bind.apply(_this$console$info,[this.console].concat(args));}},{key:"warn",value:function warn(){var _this$console$warn;for(var _len104=arguments.length,args=new Array(_len104),_key9=0;_key9<_len104;_key9++){args[_key9]=arguments[_key9];}return(_this$console$warn=this.console.warn).bind.apply(_this$console$warn,[this.console].concat(args));}},{key:"error",value:function error(){var _this$console$error;for(var _len105=arguments.length,args=new Array(_len105),_key10=0;_key10<_len105;_key10++){args[_key10]=arguments[_key10];}return(_this$console$error=this.console.error).bind.apply(_this$console$error,[this.console].concat(args));}}]);return ConsoleLog;}();var DEFAULT_LOADER_OPTIONS={fetch:null,mimeType:undefined,nothrow:false,log:new ConsoleLog(),CDN:'https://unpkg.com/@loaders.gl',worker:true,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:isBrowser$4,_nodeWorkers:false,_workerType:'',limit:0,_limitMB:0,batchSize:'auto',batchDebounceMs:0,metadata:false,transforms:[]};var REMOVED_LOADER_OPTIONS={"throws":'nothrow',dataType:'(no longer used)',uri:'baseUri',method:'fetch.method',headers:'fetch.headers',body:'fetch.body',mode:'fetch.mode',credentials:'fetch.credentials',cache:'fetch.cache',redirect:'fetch.redirect',referrer:'fetch.referrer',referrerPolicy:'fetch.referrerPolicy',integrity:'fetch.integrity',keepalive:'fetch.keepalive',signal:'fetch.signal'};function getGlobalLoaderState(){globalThis.loaders=globalThis.loaders||{};var loaders=globalThis.loaders;loaders._state=loaders._state||{};return loaders._state;}var getGlobalLoaderOptions=function getGlobalLoaderOptions(){var state=getGlobalLoaderState();state.globalOptions=state.globalOptions||_objectSpread({},DEFAULT_LOADER_OPTIONS);return state.globalOptions;};function normalizeOptions(options,loader,loaders,url){loaders=loaders||[];loaders=Array.isArray(loaders)?loaders:[loaders];validateOptions(options,loaders);return normalizeOptionsInternal(loader,options,url);}function getFetchFunction(options,context){var globalOptions=getGlobalLoaderOptions();var fetchOptions=options||globalOptions;if(typeof fetchOptions.fetch==='function'){return fetchOptions.fetch;}if(isObject(fetchOptions.fetch)){return function(url){return fetchFile(url,fetchOptions);};}if(context!==null&&context!==void 0&&context.fetch){return context===null||context===void 0?void 0:context.fetch;}return fetchFile;}function validateOptions(options,loaders){validateOptionsObject(options,null,DEFAULT_LOADER_OPTIONS,REMOVED_LOADER_OPTIONS,loaders);var _iterator9=_createForOfIteratorHelper(loaders),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var loader=_step9.value;var idOptions=options&&options[loader.id]||{};var loaderOptions=loader.options&&loader.options[loader.id]||{};var deprecatedOptions=loader.deprecatedOptions&&loader.deprecatedOptions[loader.id]||{};validateOptionsObject(idOptions,loader.id,loaderOptions,deprecatedOptions,loaders);}}catch(err){_iterator9.e(err);}finally{_iterator9.f();}}function validateOptionsObject(options,id,defaultOptions,deprecatedOptions,loaders){var loaderName=id||'Top level';var prefix=id?"".concat(id,"."):'';for(var key in options){var isSubOptions=!id&&isObject(options[key]);var isBaseUriOption=key==='baseUri'&&!id;var isWorkerUrlOption=key==='workerUrl'&&id;if(!(key in defaultOptions)&&!isBaseUriOption&&!isWorkerUrlOption){if(key in deprecatedOptions){probeLog.warn("".concat(loaderName," loader option '").concat(prefix).concat(key,"' no longer supported, use '").concat(deprecatedOptions[key],"'"))();}else if(!isSubOptions){var suggestion=findSimilarOption(key,loaders);probeLog.warn("".concat(loaderName," loader option '").concat(prefix).concat(key,"' not recognized. ").concat(suggestion))();}}}}function findSimilarOption(optionKey,loaders){var lowerCaseOptionKey=optionKey.toLowerCase();var bestSuggestion='';var _iterator10=_createForOfIteratorHelper(loaders),_step10;try{for(_iterator10.s();!(_step10=_iterator10.n()).done;){var loader=_step10.value;for(var key in loader.options){if(optionKey===key){return"Did you mean '".concat(loader.id,".").concat(key,"'?");}var lowerCaseKey=key.toLowerCase();var isPartialMatch=lowerCaseOptionKey.startsWith(lowerCaseKey)||lowerCaseKey.startsWith(lowerCaseOptionKey);if(isPartialMatch){bestSuggestion=bestSuggestion||"Did you mean '".concat(loader.id,".").concat(key,"'?");}}}}catch(err){_iterator10.e(err);}finally{_iterator10.f();}return bestSuggestion;}function normalizeOptionsInternal(loader,options,url){var loaderDefaultOptions=loader.options||{};var mergedOptions=_objectSpread({},loaderDefaultOptions);addUrlOptions(mergedOptions,url);if(mergedOptions.log===null){mergedOptions.log=new NullLog();}mergeNestedFields(mergedOptions,getGlobalLoaderOptions());mergeNestedFields(mergedOptions,options);return mergedOptions;}function mergeNestedFields(mergedOptions,options){for(var key in options){if(key in options){var value=options[key];if(isPureObject(value)&&isPureObject(mergedOptions[key])){mergedOptions[key]=_objectSpread(_objectSpread({},mergedOptions[key]),options[key]);}else{mergedOptions[key]=options[key];}}}}function addUrlOptions(options,url){if(url&&!('baseUri'in options)){options.baseUri=url;}}function isLoaderObject(loader){var _loader;if(!loader){return false;}if(Array.isArray(loader)){loader=loader[0];}var hasExtensions=Array.isArray((_loader=loader)===null||_loader===void 0?void 0:_loader.extensions);return hasExtensions;}function normalizeLoader(loader){var _loader2,_loader3;assert$5(loader,'null loader');assert$5(isLoaderObject(loader),'invalid loader');var options;if(Array.isArray(loader)){options=loader[1];loader=loader[0];loader=_objectSpread(_objectSpread({},loader),{},{options:_objectSpread(_objectSpread({},loader.options),options)});}if((_loader2=loader)!==null&&_loader2!==void 0&&_loader2.parseTextSync||(_loader3=loader)!==null&&_loader3!==void 0&&_loader3.parseText){loader.text=true;}if(!loader.text){loader.binary=true;}return loader;}var getGlobalLoaderRegistry=function getGlobalLoaderRegistry(){var state=getGlobalLoaderState();state.loaderRegistry=state.loaderRegistry||[];return state.loaderRegistry;};function getRegisteredLoaders(){return getGlobalLoaderRegistry();}function isElectron(mockUserAgent){if(typeof window!=='undefined'&&_typeof(window.process)==='object'&&window.process.type==='renderer'){return true;}if(typeof process!=='undefined'&&_typeof(process.versions)==='object'&&Boolean(process.versions.electron)){return true;}var realUserAgent=(typeof navigator==="undefined"?"undefined":_typeof(navigator))==='object'&&typeof navigator.userAgent==='string'&&navigator.userAgent;var userAgent=mockUserAgent||realUserAgent;if(userAgent&&userAgent.indexOf('Electron')>=0){return true;}return false;}function isBrowser(){var isNode=(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&String(process)==='[object process]'&&!process.browser;return!isNode||isElectron();}var globals={self:typeof self!=='undefined'&&self,window:typeof window!=='undefined'&&window,global:typeof global!=='undefined'&&global,document:typeof document!=='undefined'&&document,process:(typeof process==="undefined"?"undefined":_typeof(process))==='object'&&process};var window_=globals.window||globals.self||globals.global;var process_=globals.process||{};var VERSION$6=typeof __VERSION__!=='undefined'?__VERSION__:'untranspiled source';isBrowser();function getStorage(type){try{var storage=window[type];var x='__storage_test__';storage.setItem(x,x);storage.removeItem(x);return storage;}catch(e){return null;}}var LocalStorage=/*#__PURE__*/function(){function LocalStorage(id){_classCallCheck(this,LocalStorage);var defaultSettings=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'sessionStorage';_defineProperty(this,"storage",void 0);_defineProperty(this,"id",void 0);_defineProperty(this,"config",{});this.storage=getStorage(type);this.id=id;this.config={};Object.assign(this.config,defaultSettings);this._loadConfiguration();}_createClass(LocalStorage,[{key:"getConfiguration",value:function getConfiguration(){return this.config;}},{key:"setConfiguration",value:function setConfiguration(configuration){this.config={};return this.updateConfiguration(configuration);}},{key:"updateConfiguration",value:function updateConfiguration(configuration){Object.assign(this.config,configuration);if(this.storage){var serialized=JSON.stringify(this.config);this.storage.setItem(this.id,serialized);}return this;}},{key:"_loadConfiguration",value:function _loadConfiguration(){var configuration={};if(this.storage){var serializedConfiguration=this.storage.getItem(this.id);configuration=serializedConfiguration?JSON.parse(serializedConfiguration):{};}Object.assign(this.config,configuration);return this;}}]);return LocalStorage;}();function formatTime(ms){var formatted;if(ms<10){formatted="".concat(ms.toFixed(2),"ms");}else if(ms<100){formatted="".concat(ms.toFixed(1),"ms");}else if(ms<1000){formatted="".concat(ms.toFixed(0),"ms");}else{formatted="".concat((ms/1000).toFixed(2),"s");}return formatted;}function leftPad(string){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:8;var padLength=Math.max(length-string.length,0);return"".concat(' '.repeat(padLength)).concat(string);}function formatImage(image,message,scale){var maxWidth=arguments.length>3&&arguments[3]!==undefined?arguments[3]:600;var imageUrl=image.src.replace(/\(/g,'%28').replace(/\)/g,'%29');if(image.width>maxWidth){scale=Math.min(scale,maxWidth/image.width);}var width=image.width*scale;var height=image.height*scale;var style=['font-size:1px;',"padding:".concat(Math.floor(height/2),"px ").concat(Math.floor(width/2),"px;"),"line-height:".concat(height,"px;"),"background:url(".concat(imageUrl,");"),"background-size:".concat(width,"px ").concat(height,"px;"),'color:transparent;'].join('');return["".concat(message," %c+"),style];}var COLOR;(function(COLOR){COLOR[COLOR["BLACK"]=30]="BLACK";COLOR[COLOR["RED"]=31]="RED";COLOR[COLOR["GREEN"]=32]="GREEN";COLOR[COLOR["YELLOW"]=33]="YELLOW";COLOR[COLOR["BLUE"]=34]="BLUE";COLOR[COLOR["MAGENTA"]=35]="MAGENTA";COLOR[COLOR["CYAN"]=36]="CYAN";COLOR[COLOR["WHITE"]=37]="WHITE";COLOR[COLOR["BRIGHT_BLACK"]=90]="BRIGHT_BLACK";COLOR[COLOR["BRIGHT_RED"]=91]="BRIGHT_RED";COLOR[COLOR["BRIGHT_GREEN"]=92]="BRIGHT_GREEN";COLOR[COLOR["BRIGHT_YELLOW"]=93]="BRIGHT_YELLOW";COLOR[COLOR["BRIGHT_BLUE"]=94]="BRIGHT_BLUE";COLOR[COLOR["BRIGHT_MAGENTA"]=95]="BRIGHT_MAGENTA";COLOR[COLOR["BRIGHT_CYAN"]=96]="BRIGHT_CYAN";COLOR[COLOR["BRIGHT_WHITE"]=97]="BRIGHT_WHITE";})(COLOR||(COLOR={}));function getColor(color){return typeof color==='string'?COLOR[color.toUpperCase()]||COLOR.WHITE:color;}function addColor(string,color,background){if(!isBrowser&&typeof string==='string'){if(color){color=getColor(color);string="\x1B[".concat(color,"m").concat(string,"\x1B[39m");}if(background){color=getColor(background);string="\x1B[".concat(background+10,"m").concat(string,"\x1B[49m");}}return string;}function autobind(obj){var predefined=arguments.length>1&&arguments[1]!==undefined?arguments[1]:['constructor'];var proto=Object.getPrototypeOf(obj);var propNames=Object.getOwnPropertyNames(proto);var _iterator11=_createForOfIteratorHelper(propNames),_step11;try{var _loop5=function _loop5(){var key=_step11.value;if(typeof obj[key]==='function'){if(!predefined.find(function(name){return key===name;})){obj[key]=obj[key].bind(obj);}}};for(_iterator11.s();!(_step11=_iterator11.n()).done;){_loop5();}}catch(err){_iterator11.e(err);}finally{_iterator11.f();}}function assert$2(condition,message){if(!condition){throw new Error(message||'Assertion failed');}}function getHiResTimestamp(){var timestamp;if(isBrowser&&'performance'in window_){var _window$performance,_window$performance$n;timestamp=window_===null||window_===void 0?void 0:(_window$performance=window_.performance)===null||_window$performance===void 0?void 0:(_window$performance$n=_window$performance.now)===null||_window$performance$n===void 0?void 0:_window$performance$n.call(_window$performance);}else if('hrtime'in process_){var _process$hrtime;var timeParts=process_===null||process_===void 0?void 0:(_process$hrtime=process_.hrtime)===null||_process$hrtime===void 0?void 0:_process$hrtime.call(process_);timestamp=timeParts[0]*1000+timeParts[1]/1e6;}else{timestamp=Date.now();}return timestamp;}var originalConsole={debug:isBrowser?console.debug||console.log:console.log,log:console.log,info:console.info,warn:console.warn,error:console.error};var DEFAULT_SETTINGS={enabled:true,level:0};function noop(){}var cache={};var ONCE={once:true};var Log=/*#__PURE__*/function(){function Log(){_classCallCheck(this,Log);var _ref22=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{id:''},id=_ref22.id;_defineProperty(this,"id",void 0);_defineProperty(this,"VERSION",VERSION$6);_defineProperty(this,"_startTs",getHiResTimestamp());_defineProperty(this,"_deltaTs",getHiResTimestamp());_defineProperty(this,"_storage",void 0);_defineProperty(this,"userData",{});_defineProperty(this,"LOG_THROTTLE_TIMEOUT",0);this.id=id;this._storage=new LocalStorage("__probe-".concat(this.id,"__"),DEFAULT_SETTINGS);this.userData={};this.timeStamp("".concat(this.id," started"));autobind(this);Object.seal(this);}_createClass(Log,[{key:"level",get:function get(){return this.getLevel();},set:function set(newLevel){this.setLevel(newLevel);}},{key:"isEnabled",value:function isEnabled(){return this._storage.config.enabled;}},{key:"getLevel",value:function getLevel(){return this._storage.config.level;}},{key:"getTotal",value:function getTotal(){return Number((getHiResTimestamp()-this._startTs).toPrecision(10));}},{key:"getDelta",value:function getDelta(){return Number((getHiResTimestamp()-this._deltaTs).toPrecision(10));}},{key:"priority",get:function get(){return this.level;},set:function set(newPriority){this.level=newPriority;}},{key:"getPriority",value:function getPriority(){return this.level;}},{key:"enable",value:function enable(){var enabled=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;this._storage.updateConfiguration({enabled:enabled});return this;}},{key:"setLevel",value:function setLevel(level){this._storage.updateConfiguration({level:level});return this;}},{key:"get",value:function get(setting){return this._storage.config[setting];}},{key:"set",value:function set(setting,value){this._storage.updateConfiguration(_defineProperty2({},setting,value));}},{key:"settings",value:function settings(){if(console.table){console.table(this._storage.config);}else{console.log(this._storage.config);}}},{key:"assert",value:function assert(condition,message){assert$2(condition,message);}},{key:"warn",value:function warn(message){return this._getLogFunction(0,message,originalConsole.warn,arguments,ONCE);}},{key:"error",value:function error(message){return this._getLogFunction(0,message,originalConsole.error,arguments);}},{key:"deprecated",value:function deprecated(oldUsage,newUsage){return this.warn("`".concat(oldUsage,"` is deprecated and will be removed in a later version. Use `").concat(newUsage,"` instead"));}},{key:"removed",value:function removed(oldUsage,newUsage){return this.error("`".concat(oldUsage,"` has been removed. Use `").concat(newUsage,"` instead"));}},{key:"probe",value:function probe(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole.log,arguments,{time:true,once:true});}},{key:"log",value:function log(logLevel,message){return this._getLogFunction(logLevel,message,originalConsole.debug,arguments);}},{key:"info",value:function info(logLevel,message){return this._getLogFunction(logLevel,message,console.info,arguments);}},{key:"once",value:function once(logLevel,message){for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key];}return this._getLogFunction(logLevel,message,originalConsole.debug||originalConsole.info,arguments,ONCE);}},{key:"table",value:function table(logLevel,_table2,columns){if(_table2){return this._getLogFunction(logLevel,_table2,console.table||noop,columns&&[columns],{tag:getTableHeader(_table2)});}return noop;}},{key:"image",value:function image(_ref){var logLevel=_ref.logLevel,priority=_ref.priority,image=_ref.image,_ref$message=_ref.message,message=_ref$message===void 0?'':_ref$message,_ref$scale=_ref.scale,scale=_ref$scale===void 0?1:_ref$scale;if(!this._shouldLog(logLevel||priority)){return noop;}return isBrowser?logImageInBrowser({image:image,message:message,scale:scale}):logImageInNode({image:image,message:message,scale:scale});}},{key:"time",value:function time(logLevel,message){return this._getLogFunction(logLevel,message,console.time?console.time:console.info);}},{key:"timeEnd",value:function timeEnd(logLevel,message){return this._getLogFunction(logLevel,message,console.timeEnd?console.timeEnd:console.info);}},{key:"timeStamp",value:function timeStamp(logLevel,message){return this._getLogFunction(logLevel,message,console.timeStamp||noop);}},{key:"group",value:function group(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{collapsed:false};var options=normalizeArguments({logLevel:logLevel,message:message,opts:opts});var collapsed=opts.collapsed;options.method=(collapsed?console.groupCollapsed:console.group)||console.info;return this._getLogFunction(options);}},{key:"groupCollapsed",value:function groupCollapsed(logLevel,message){var opts=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return this.group(logLevel,message,Object.assign({},opts,{collapsed:true}));}},{key:"groupEnd",value:function groupEnd(logLevel){return this._getLogFunction(logLevel,'',console.groupEnd||noop);}},{key:"withGroup",value:function withGroup(logLevel,message,func){this.group(logLevel,message)();try{func();}finally{this.groupEnd(logLevel)();}}},{key:"trace",value:function trace(){if(console.trace){console.trace();}}},{key:"_shouldLog",value:function _shouldLog(logLevel){return this.isEnabled()&&this.getLevel()>=normalizeLogLevel(logLevel);}},{key:"_getLogFunction",value:function _getLogFunction(logLevel,message,method,args,opts){if(this._shouldLog(logLevel)){var _method2;opts=normalizeArguments({logLevel:logLevel,message:message,args:args,opts:opts});method=method||opts.method;assert$2(method);opts.total=this.getTotal();opts.delta=this.getDelta();this._deltaTs=getHiResTimestamp();var tag=opts.tag||opts.message;if(opts.once){if(!cache[tag]){cache[tag]=getHiResTimestamp();}else{return noop;}}message=decorateMessage(this.id,opts.message,opts);return(_method2=method).bind.apply(_method2,[console,message].concat(_toConsumableArray(opts.args)));}return noop;}}]);return Log;}();_defineProperty(Log,"VERSION",VERSION$6);function normalizeLogLevel(logLevel){if(!logLevel){return 0;}var resolvedLevel;switch(_typeof(logLevel)){case'number':resolvedLevel=logLevel;break;case'object':resolvedLevel=logLevel.logLevel||logLevel.priority||0;break;default:return 0;}assert$2(Number.isFinite(resolvedLevel)&&resolvedLevel>=0);return resolvedLevel;}function normalizeArguments(opts){var logLevel=opts.logLevel,message=opts.message;opts.logLevel=normalizeLogLevel(logLevel);var args=opts.args?Array.from(opts.args):[];while(args.length&&args.shift()!==message){}switch(_typeof(logLevel)){case'string':case'function':if(message!==undefined){args.unshift(message);}opts.message=logLevel;break;case'object':Object.assign(opts,logLevel);break;}if(typeof opts.message==='function'){opts.message=opts.message();}var messageType=_typeof(opts.message);assert$2(messageType==='string'||messageType==='object');return Object.assign(opts,{args:args},opts.opts);}function decorateMessage(id,message,opts){if(typeof message==='string'){var _time2=opts.time?leftPad(formatTime(opts.total)):'';message=opts.time?"".concat(id,": ").concat(_time2," ").concat(message):"".concat(id,": ").concat(message);message=addColor(message,opts.color,opts.background);}return message;}function logImageInNode(_ref2){var image=_ref2.image,_ref2$message=_ref2.message,message=_ref2$message===void 0?'':_ref2$message,_ref2$scale=_ref2.scale,scale=_ref2$scale===void 0?1:_ref2$scale;var asciify=null;try{asciify=module.require('asciify-image');}catch(error){}if(asciify){return function(){return asciify(image,{fit:'box',width:"".concat(Math.round(80*scale),"%")}).then(function(data){return console.log(data);});};}return noop;}function logImageInBrowser(_ref3){var image=_ref3.image,_ref3$message=_ref3.message,message=_ref3$message===void 0?'':_ref3$message,_ref3$scale=_ref3.scale,scale=_ref3$scale===void 0?1:_ref3$scale;if(typeof image==='string'){var img=new Image();img.onload=function(){var _console4;var args=formatImage(img,message,scale);(_console4=console).log.apply(_console4,_toConsumableArray(args));};img.src=image;return noop;}var element=image.nodeName||'';if(element.toLowerCase()==='img'){var _console5;(_console5=console).log.apply(_console5,_toConsumableArray(formatImage(image,message,scale)));return noop;}if(element.toLowerCase()==='canvas'){var _img2=new Image();_img2.onload=function(){var _console6;return(_console6=console).log.apply(_console6,_toConsumableArray(formatImage(_img2,message,scale)));};_img2.src=image.toDataURL();return noop;}return noop;}function getTableHeader(table){for(var key in table){for(var title in table[key]){return title||'untitled';}}return'empty';}var log=new Log({id:'loaders.gl'});var EXT_PATTERN=/\.([^.]+)$/;function selectLoader(_x27){return _selectLoader.apply(this,arguments);}function _selectLoader(){_selectLoader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(data){var loaders,options,context,loader,_args16=arguments;return _regeneratorRuntime().wrap(function _callee18$(_context22){while(1){switch(_context22.prev=_context22.next){case 0:loaders=_args16.length>1&&_args16[1]!==undefined?_args16[1]:[];options=_args16.length>2?_args16[2]:undefined;context=_args16.length>3?_args16[3]:undefined;if(validHTTPResponse(data)){_context22.next=5;break;}return _context22.abrupt("return",null);case 5:loader=selectLoaderSync(data,loaders,_objectSpread(_objectSpread({},options),{},{nothrow:true}),context);if(!loader){_context22.next=8;break;}return _context22.abrupt("return",loader);case 8:if(!isBlob(data)){_context22.next=13;break;}_context22.next=11;return data.slice(0,10).arrayBuffer();case 11:data=_context22.sent;loader=selectLoaderSync(data,loaders,options,context);case 13:if(!(!loader&&!(options!==null&&options!==void 0&&options.nothrow))){_context22.next=15;break;}throw new Error(getNoValidLoaderMessage(data));case 15:return _context22.abrupt("return",loader);case 16:case"end":return _context22.stop();}}},_callee18);}));return _selectLoader.apply(this,arguments);}function selectLoaderSync(data){var loaders=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var options=arguments.length>2?arguments[2]:undefined;var context=arguments.length>3?arguments[3]:undefined;if(!validHTTPResponse(data)){return null;}if(loaders&&!Array.isArray(loaders)){return normalizeLoader(loaders);}var candidateLoaders=[];if(loaders){candidateLoaders=candidateLoaders.concat(loaders);}if(!(options!==null&&options!==void 0&&options.ignoreRegisteredLoaders)){var _candidateLoaders;(_candidateLoaders=candidateLoaders).push.apply(_candidateLoaders,_toConsumableArray(getRegisteredLoaders()));}normalizeLoaders(candidateLoaders);var loader=selectLoaderInternal(data,candidateLoaders,options,context);if(!loader&&!(options!==null&&options!==void 0&&options.nothrow)){throw new Error(getNoValidLoaderMessage(data));}return loader;}function selectLoaderInternal(data,loaders,options,context){var _getResourceUrlAndTyp=getResourceUrlAndType(data),url=_getResourceUrlAndTyp.url,type=_getResourceUrlAndTyp.type;var testUrl=url||(context===null||context===void 0?void 0:context.url);var loader=null;var reason='';if(options!==null&&options!==void 0&&options.mimeType){loader=findLoaderByMIMEType(loaders,options===null||options===void 0?void 0:options.mimeType);reason="match forced by supplied MIME type ".concat(options===null||options===void 0?void 0:options.mimeType);}loader=loader||findLoaderByUrl(loaders,testUrl);reason=reason||(loader?"matched url ".concat(testUrl):'');loader=loader||findLoaderByMIMEType(loaders,type);reason=reason||(loader?"matched MIME type ".concat(type):'');loader=loader||findLoaderByInitialBytes(loaders,data);reason=reason||(loader?"matched initial data ".concat(getFirstCharacters(data)):'');loader=loader||findLoaderByMIMEType(loaders,options===null||options===void 0?void 0:options.fallbackMimeType);reason=reason||(loader?"matched fallback MIME type ".concat(type):'');if(reason){var _loader;log.log(1,"selectLoader selected ".concat((_loader=loader)===null||_loader===void 0?void 0:_loader.name,": ").concat(reason,"."));}return loader;}function validHTTPResponse(data){if(data instanceof Response){if(data.status===204){return false;}}return true;}function getNoValidLoaderMessage(data){var _getResourceUrlAndTyp2=getResourceUrlAndType(data),url=_getResourceUrlAndTyp2.url,type=_getResourceUrlAndTyp2.type;var message='No valid loader found (';message+=url?"".concat(filename(url),", "):'no url provided, ';message+="MIME type: ".concat(type?"\"".concat(type,"\""):'not provided',", ");var firstCharacters=data?getFirstCharacters(data):'';message+=firstCharacters?" first bytes: \"".concat(firstCharacters,"\""):'first bytes: not available';message+=')';return message;}function normalizeLoaders(loaders){var _iterator12=_createForOfIteratorHelper(loaders),_step12;try{for(_iterator12.s();!(_step12=_iterator12.n()).done;){var loader=_step12.value;normalizeLoader(loader);}}catch(err){_iterator12.e(err);}finally{_iterator12.f();}}function findLoaderByUrl(loaders,url){var match=url&&EXT_PATTERN.exec(url);var extension=match&&match[1];return extension?findLoaderByExtension(loaders,extension):null;}function findLoaderByExtension(loaders,extension){extension=extension.toLowerCase();var _iterator13=_createForOfIteratorHelper(loaders),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var loader=_step13.value;var _iterator14=_createForOfIteratorHelper(loader.extensions),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var loaderExtension=_step14.value;if(loaderExtension.toLowerCase()===extension){return loader;}}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}return null;}function findLoaderByMIMEType(loaders,mimeType){var _iterator15=_createForOfIteratorHelper(loaders),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var loader=_step15.value;if(loader.mimeTypes&&loader.mimeTypes.includes(mimeType)){return loader;}if(mimeType==="application/x.".concat(loader.id)){return loader;}}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}return null;}function findLoaderByInitialBytes(loaders,data){if(!data){return null;}var _iterator16=_createForOfIteratorHelper(loaders),_step16;try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){var loader=_step16.value;if(typeof data==='string'){if(testDataAgainstText(data,loader)){return loader;}}else if(ArrayBuffer.isView(data)){if(testDataAgainstBinary(data.buffer,data.byteOffset,loader)){return loader;}}else if(data instanceof ArrayBuffer){var byteOffset=0;if(testDataAgainstBinary(data,byteOffset,loader)){return loader;}}}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}return null;}function testDataAgainstText(data,loader){if(loader.testText){return loader.testText(data);}var tests=Array.isArray(loader.tests)?loader.tests:[loader.tests];return tests.some(function(test){return data.startsWith(test);});}function testDataAgainstBinary(data,byteOffset,loader){var tests=Array.isArray(loader.tests)?loader.tests:[loader.tests];return tests.some(function(test){return testBinary(data,byteOffset,loader,test);});}function testBinary(data,byteOffset,loader,test){if(test instanceof ArrayBuffer){return compareArrayBuffers(test,data,test.byteLength);}switch(_typeof(test)){case'function':return test(data,loader);case'string':var magic=getMagicString$1(data,byteOffset,test.length);return test===magic;default:return false;}}function getFirstCharacters(data){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5;if(typeof data==='string'){return data.slice(0,length);}else if(ArrayBuffer.isView(data)){return getMagicString$1(data.buffer,data.byteOffset,length);}else if(data instanceof ArrayBuffer){var byteOffset=0;return getMagicString$1(data,byteOffset,length);}return'';}function getMagicString$1(arrayBuffer,byteOffset,length){if(arrayBuffer.byteLength<byteOffset+length){return'';}var dataView=new DataView(arrayBuffer);var magic='';for(var _i513=0;_i513<length;_i513++){magic+=String.fromCharCode(dataView.getUint8(byteOffset+_i513));}return magic;}var DEFAULT_CHUNK_SIZE$2=256*1024;function makeStringIterator(string,options){var chunkSize,offset,textEncoder,chunkLength,chunk;return _regeneratorRuntime().wrap(function makeStringIterator$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:chunkSize=(options===null||options===void 0?void 0:options.chunkSize)||DEFAULT_CHUNK_SIZE$2;offset=0;textEncoder=new TextEncoder();case 3:if(!(offset<string.length)){_context5.next=11;break;}chunkLength=Math.min(string.length-offset,chunkSize);chunk=string.slice(offset,offset+chunkLength);offset+=chunkLength;_context5.next=9;return textEncoder.encode(chunk);case 9:_context5.next=3;break;case 11:case"end":return _context5.stop();}}},_marked);}var DEFAULT_CHUNK_SIZE$1=256*1024;function makeArrayBufferIterator(arrayBuffer){var options,_options$chunkSize,chunkSize,byteOffset,chunkByteLength,chunk,sourceArray,_chunkArray,_args5=arguments;return _regeneratorRuntime().wrap(function makeArrayBufferIterator$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:options=_args5.length>1&&_args5[1]!==undefined?_args5[1]:{};_options$chunkSize=options.chunkSize,chunkSize=_options$chunkSize===void 0?DEFAULT_CHUNK_SIZE$1:_options$chunkSize;byteOffset=0;case 3:if(!(byteOffset<arrayBuffer.byteLength)){_context6.next=14;break;}chunkByteLength=Math.min(arrayBuffer.byteLength-byteOffset,chunkSize);chunk=new ArrayBuffer(chunkByteLength);sourceArray=new Uint8Array(arrayBuffer,byteOffset,chunkByteLength);_chunkArray=new Uint8Array(chunk);_chunkArray.set(sourceArray);byteOffset+=chunkByteLength;_context6.next=12;return chunk;case 12:_context6.next=3;break;case 14:case"end":return _context6.stop();}}},_marked2);}var DEFAULT_CHUNK_SIZE=1024*1024;function makeBlobIterator(_x,_x2){return _makeBlobIterator.apply(this,arguments);}function _makeBlobIterator(){_makeBlobIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(blob,options){var chunkSize,offset,end,chunk;return _regeneratorRuntime().wrap(function _callee4$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:chunkSize=(options===null||options===void 0?void 0:options.chunkSize)||DEFAULT_CHUNK_SIZE;offset=0;case 2:if(!(offset<blob.size)){_context7.next=12;break;}end=offset+chunkSize;_context7.next=6;return _awaitAsyncGenerator(blob.slice(offset,end).arrayBuffer());case 6:chunk=_context7.sent;offset=end;_context7.next=10;return chunk;case 10:_context7.next=2;break;case 12:case"end":return _context7.stop();}}},_callee4);}));return _makeBlobIterator.apply(this,arguments);}function makeStreamIterator(stream,options){return isBrowser$4?makeBrowserStreamIterator(stream,options):makeNodeStreamIterator(stream);}function makeBrowserStreamIterator(_x3,_x4){return _makeBrowserStreamIterator.apply(this,arguments);}function _makeBrowserStreamIterator(){_makeBrowserStreamIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(stream,options){var reader,nextBatchPromise,currentBatchPromise,_yield$_awaitAsyncGen,done,value;return _regeneratorRuntime().wrap(function _callee5$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:reader=stream.getReader();_context8.prev=1;case 2:if(!true){_context8.next=16;break;}currentBatchPromise=nextBatchPromise||reader.read();if(options!==null&&options!==void 0&&options._streamReadAhead){nextBatchPromise=reader.read();}_context8.next=7;return _awaitAsyncGenerator(currentBatchPromise);case 7:_yield$_awaitAsyncGen=_context8.sent;done=_yield$_awaitAsyncGen.done;value=_yield$_awaitAsyncGen.value;if(!done){_context8.next=12;break;}return _context8.abrupt("return");case 12:_context8.next=14;return toArrayBuffer(value);case 14:_context8.next=2;break;case 16:_context8.next=21;break;case 18:_context8.prev=18;_context8.t0=_context8["catch"](1);reader.releaseLock();case 21:case"end":return _context8.stop();}}},_callee5,null,[[1,18]]);}));return _makeBrowserStreamIterator.apply(this,arguments);}function makeNodeStreamIterator(_x5,_x6){return _makeNodeStreamIterator.apply(this,arguments);}function _makeNodeStreamIterator(){_makeNodeStreamIterator=_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(stream,options){var _iteratorAbruptCompletion2,_didIteratorError2,_iteratorError2,_iterator2,_step2,chunk;return _regeneratorRuntime().wrap(function _callee6$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:_iteratorAbruptCompletion2=false;_didIteratorError2=false;_context9.prev=2;_iterator2=_asyncIterator(stream);case 4:_context9.next=6;return _awaitAsyncGenerator(_iterator2.next());case 6:if(!(_iteratorAbruptCompletion2=!(_step2=_context9.sent).done)){_context9.next=13;break;}chunk=_step2.value;_context9.next=10;return toArrayBuffer(chunk);case 10:_iteratorAbruptCompletion2=false;_context9.next=4;break;case 13:_context9.next=19;break;case 15:_context9.prev=15;_context9.t0=_context9["catch"](2);_didIteratorError2=true;_iteratorError2=_context9.t0;case 19:_context9.prev=19;_context9.prev=20;if(!(_iteratorAbruptCompletion2&&_iterator2["return"]!=null)){_context9.next=24;break;}_context9.next=24;return _awaitAsyncGenerator(_iterator2["return"]());case 24:_context9.prev=24;if(!_didIteratorError2){_context9.next=27;break;}throw _iteratorError2;case 27:return _context9.finish(24);case 28:return _context9.finish(19);case 29:case"end":return _context9.stop();}}},_callee6,null,[[2,15,19,29],[20,,24,28]]);}));return _makeNodeStreamIterator.apply(this,arguments);}function makeIterator(data,options){if(typeof data==='string'){return makeStringIterator(data,options);}if(data instanceof ArrayBuffer){return makeArrayBufferIterator(data,options);}if(isBlob(data)){return makeBlobIterator(data,options);}if(isReadableStream(data)){return makeStreamIterator(data,options);}if(isResponse(data)){var response=data;return makeStreamIterator(response.body,options);}throw new Error('makeIterator');}var ERR_DATA='Cannot convert supplied data type';function getArrayBufferOrStringFromDataSync(data,loader,options){if(loader.text&&typeof data==='string'){return data;}if(isBuffer(data)){data=data.buffer;}if(data instanceof ArrayBuffer){var arrayBuffer=data;if(loader.text&&!loader.binary){var textDecoder=new TextDecoder('utf8');return textDecoder.decode(arrayBuffer);}return arrayBuffer;}if(ArrayBuffer.isView(data)){if(loader.text&&!loader.binary){var _textDecoder=new TextDecoder('utf8');return _textDecoder.decode(data);}var _arrayBuffer=data.buffer;var byteLength=data.byteLength||data.length;if(data.byteOffset!==0||byteLength!==_arrayBuffer.byteLength){_arrayBuffer=_arrayBuffer.slice(data.byteOffset,data.byteOffset+byteLength);}return _arrayBuffer;}throw new Error(ERR_DATA);}function getArrayBufferOrStringFromData(_x28,_x29,_x30){return _getArrayBufferOrStringFromData.apply(this,arguments);}function _getArrayBufferOrStringFromData(){_getArrayBufferOrStringFromData=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data,loader,options){var isArrayBuffer,response;return _regeneratorRuntime().wrap(function _callee19$(_context23){while(1){switch(_context23.prev=_context23.next){case 0:isArrayBuffer=data instanceof ArrayBuffer||ArrayBuffer.isView(data);if(!(typeof data==='string'||isArrayBuffer)){_context23.next=3;break;}return _context23.abrupt("return",getArrayBufferOrStringFromDataSync(data,loader));case 3:if(!isBlob(data)){_context23.next=7;break;}_context23.next=6;return makeResponse(data);case 6:data=_context23.sent;case 7:if(!isResponse(data)){_context23.next=21;break;}response=data;_context23.next=11;return checkResponse(response);case 11:if(!loader.binary){_context23.next=17;break;}_context23.next=14;return response.arrayBuffer();case 14:_context23.t0=_context23.sent;_context23.next=20;break;case 17:_context23.next=19;return response.text();case 19:_context23.t0=_context23.sent;case 20:return _context23.abrupt("return",_context23.t0);case 21:if(isReadableStream(data)){data=makeIterator(data,options);}if(!(isIterable(data)||isAsyncIterable(data))){_context23.next=24;break;}return _context23.abrupt("return",concatenateArrayBuffersAsync(data));case 24:throw new Error(ERR_DATA);case 25:case"end":return _context23.stop();}}},_callee19);}));return _getArrayBufferOrStringFromData.apply(this,arguments);}function getLoaderContext(context,options){var previousContext=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(previousContext){return previousContext;}var resolvedContext=_objectSpread({fetch:getFetchFunction(options,context)},context);if(!Array.isArray(resolvedContext.loaders)){resolvedContext.loaders=null;}return resolvedContext;}function getLoadersFromContext(loaders,context){if(!context&&loaders&&!Array.isArray(loaders)){return loaders;}var candidateLoaders;if(loaders){candidateLoaders=Array.isArray(loaders)?loaders:[loaders];}if(context&&context.loaders){var contextLoaders=Array.isArray(context.loaders)?context.loaders:[context.loaders];candidateLoaders=candidateLoaders?[].concat(_toConsumableArray(candidateLoaders),_toConsumableArray(contextLoaders)):contextLoaders;}return candidateLoaders&&candidateLoaders.length?candidateLoaders:null;}function parse$3(_x31,_x32,_x33,_x34){return _parse$.apply(this,arguments);}function _parse$(){_parse$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(data,loaders,options,context){var _getResourceUrlAndTyp4,url,typedLoaders,candidateLoaders,loader;return _regeneratorRuntime().wrap(function _callee20$(_context24){while(1){switch(_context24.prev=_context24.next){case 0:assert$4(!context||_typeof(context)==='object');if(loaders&&!Array.isArray(loaders)&&!isLoaderObject(loaders)){context=undefined;options=loaders;loaders=undefined;}_context24.next=4;return data;case 4:data=_context24.sent;options=options||{};_getResourceUrlAndTyp4=getResourceUrlAndType(data),url=_getResourceUrlAndTyp4.url;typedLoaders=loaders;candidateLoaders=getLoadersFromContext(typedLoaders,context);_context24.next=11;return selectLoader(data,candidateLoaders,options);case 11:loader=_context24.sent;if(loader){_context24.next=14;break;}return _context24.abrupt("return",null);case 14:options=normalizeOptions(options,loader,candidateLoaders,url);context=getLoaderContext({url:url,parse:parse$3,loaders:candidateLoaders},options,context);_context24.next=18;return parseWithLoader(loader,data,options,context);case 18:return _context24.abrupt("return",_context24.sent);case 19:case"end":return _context24.stop();}}},_callee20);}));return _parse$.apply(this,arguments);}function parseWithLoader(_x35,_x36,_x37,_x38){return _parseWithLoader.apply(this,arguments);}function _parseWithLoader(){_parseWithLoader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(loader,data,options,context){var response,ok,redirected,status,statusText,type,url,headers;return _regeneratorRuntime().wrap(function _callee21$(_context25){while(1){switch(_context25.prev=_context25.next){case 0:validateWorkerVersion(loader);if(isResponse(data)){response=data;ok=response.ok,redirected=response.redirected,status=response.status,statusText=response.statusText,type=response.type,url=response.url;headers=Object.fromEntries(response.headers.entries());context.response={headers:headers,ok:ok,redirected:redirected,status:status,statusText:statusText,type:type,url:url};}_context25.next=4;return getArrayBufferOrStringFromData(data,loader,options);case 4:data=_context25.sent;if(!(loader.parseTextSync&&typeof data==='string')){_context25.next=8;break;}options.dataType='text';return _context25.abrupt("return",loader.parseTextSync(data,options,context,loader));case 8:if(!canParseWithWorker(loader,options)){_context25.next=12;break;}_context25.next=11;return parseWithWorker(loader,data,options,context,parse$3);case 11:return _context25.abrupt("return",_context25.sent);case 12:if(!(loader.parseText&&typeof data==='string')){_context25.next=16;break;}_context25.next=15;return loader.parseText(data,options,context,loader);case 15:return _context25.abrupt("return",_context25.sent);case 16:if(!loader.parse){_context25.next=20;break;}_context25.next=19;return loader.parse(data,options,context,loader);case 19:return _context25.abrupt("return",_context25.sent);case 20:assert$4(!loader.parseSync);throw new Error("".concat(loader.id," loader - no parser found and worker is disabled"));case 22:case"end":return _context25.stop();}}},_callee21);}));return _parseWithLoader.apply(this,arguments);}var VERSION$5="3.2.6";var VERSION$4="3.2.6";var VERSION$3="3.2.6";var BASIS_CDN_ENCODER_WASM="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$3,"/dist/libs/basis_encoder.wasm");var BASIS_CDN_ENCODER_JS="https://unpkg.com/@loaders.gl/textures@".concat(VERSION$3,"/dist/libs/basis_encoder.js");var loadBasisTranscoderPromise;function loadBasisTrascoderModule(_x39){return _loadBasisTrascoderModule.apply(this,arguments);}function _loadBasisTrascoderModule(){_loadBasisTrascoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(options){var modules;return _regeneratorRuntime().wrap(function _callee22$(_context26){while(1){switch(_context26.prev=_context26.next){case 0:modules=options.modules||{};if(!modules.basis){_context26.next=3;break;}return _context26.abrupt("return",modules.basis);case 3:loadBasisTranscoderPromise=loadBasisTranscoderPromise||loadBasisTrascoder(options);_context26.next=6;return loadBasisTranscoderPromise;case 6:return _context26.abrupt("return",_context26.sent);case 7:case"end":return _context26.stop();}}},_callee22);}));return _loadBasisTrascoderModule.apply(this,arguments);}function loadBasisTrascoder(_x40){return _loadBasisTrascoder.apply(this,arguments);}function _loadBasisTrascoder(){_loadBasisTrascoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(options){var BASIS,wasmBinary,_yield$Promise$all,_yield$Promise$all2;return _regeneratorRuntime().wrap(function _callee23$(_context27){while(1){switch(_context27.prev=_context27.next){case 0:BASIS=null;wasmBinary=null;_context27.t0=Promise;_context27.next=5;return loadLibrary('basis_transcoder.js','textures',options);case 5:_context27.t1=_context27.sent;_context27.next=8;return loadLibrary('basis_transcoder.wasm','textures',options);case 8:_context27.t2=_context27.sent;_context27.t3=[_context27.t1,_context27.t2];_context27.next=12;return _context27.t0.all.call(_context27.t0,_context27.t3);case 12:_yield$Promise$all=_context27.sent;_yield$Promise$all2=_slicedToArray(_yield$Promise$all,2);BASIS=_yield$Promise$all2[0];wasmBinary=_yield$Promise$all2[1];BASIS=BASIS||globalThis.BASIS;_context27.next=19;return initializeBasisTrascoderModule(BASIS,wasmBinary);case 19:return _context27.abrupt("return",_context27.sent);case 20:case"end":return _context27.stop();}}},_callee23);}));return _loadBasisTrascoder.apply(this,arguments);}function initializeBasisTrascoderModule(BasisModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){BasisModule(options).then(function(module){var BasisFile=module.BasisFile,initializeBasis=module.initializeBasis;initializeBasis();resolve({BasisFile:BasisFile});});});}var loadBasisEncoderPromise;function loadBasisEncoderModule(_x41){return _loadBasisEncoderModule.apply(this,arguments);}function _loadBasisEncoderModule(){_loadBasisEncoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(options){var modules;return _regeneratorRuntime().wrap(function _callee24$(_context28){while(1){switch(_context28.prev=_context28.next){case 0:modules=options.modules||{};if(!modules.basisEncoder){_context28.next=3;break;}return _context28.abrupt("return",modules.basisEncoder);case 3:loadBasisEncoderPromise=loadBasisEncoderPromise||loadBasisEncoder(options);_context28.next=6;return loadBasisEncoderPromise;case 6:return _context28.abrupt("return",_context28.sent);case 7:case"end":return _context28.stop();}}},_callee24);}));return _loadBasisEncoderModule.apply(this,arguments);}function loadBasisEncoder(_x42){return _loadBasisEncoder.apply(this,arguments);}function _loadBasisEncoder(){_loadBasisEncoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(options){var BASIS_ENCODER,wasmBinary,_yield$Promise$all3,_yield$Promise$all4;return _regeneratorRuntime().wrap(function _callee25$(_context29){while(1){switch(_context29.prev=_context29.next){case 0:BASIS_ENCODER=null;wasmBinary=null;_context29.t0=Promise;_context29.next=5;return loadLibrary(BASIS_CDN_ENCODER_JS,'textures',options);case 5:_context29.t1=_context29.sent;_context29.next=8;return loadLibrary(BASIS_CDN_ENCODER_WASM,'textures',options);case 8:_context29.t2=_context29.sent;_context29.t3=[_context29.t1,_context29.t2];_context29.next=12;return _context29.t0.all.call(_context29.t0,_context29.t3);case 12:_yield$Promise$all3=_context29.sent;_yield$Promise$all4=_slicedToArray(_yield$Promise$all3,2);BASIS_ENCODER=_yield$Promise$all4[0];wasmBinary=_yield$Promise$all4[1];BASIS_ENCODER=BASIS_ENCODER||globalThis.BASIS;_context29.next=19;return initializeBasisEncoderModule(BASIS_ENCODER,wasmBinary);case 19:return _context29.abrupt("return",_context29.sent);case 20:case"end":return _context29.stop();}}},_callee25);}));return _loadBasisEncoder.apply(this,arguments);}function initializeBasisEncoderModule(BasisEncoderModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){BasisEncoderModule(options).then(function(module){var BasisFile=module.BasisFile,KTX2File=module.KTX2File,initializeBasis=module.initializeBasis,BasisEncoder=module.BasisEncoder;initializeBasis();resolve({BasisFile:BasisFile,KTX2File:KTX2File,BasisEncoder:BasisEncoder});});});}var GL_EXTENSIONS_CONSTANTS={COMPRESSED_RGB_S3TC_DXT1_EXT:0x83f0,COMPRESSED_RGBA_S3TC_DXT1_EXT:0x83f1,COMPRESSED_RGBA_S3TC_DXT3_EXT:0x83f2,COMPRESSED_RGBA_S3TC_DXT5_EXT:0x83f3,COMPRESSED_R11_EAC:0x9270,COMPRESSED_SIGNED_R11_EAC:0x9271,COMPRESSED_RG11_EAC:0x9272,COMPRESSED_SIGNED_RG11_EAC:0x9273,COMPRESSED_RGB8_ETC2:0x9274,COMPRESSED_RGBA8_ETC2_EAC:0x9275,COMPRESSED_SRGB8_ETC2:0x9276,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:0x9277,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:0x9278,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:0x9279,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:0x8c00,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:0x8c02,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:0x8c01,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:0x8c03,COMPRESSED_RGB_ETC1_WEBGL:0x8d64,COMPRESSED_RGB_ATC_WEBGL:0x8c92,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:0x8c93,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:0x87ee,COMPRESSED_RGBA_ASTC_4X4_KHR:0x93b0,COMPRESSED_RGBA_ASTC_5X4_KHR:0x93b1,COMPRESSED_RGBA_ASTC_5X5_KHR:0x93b2,COMPRESSED_RGBA_ASTC_6X5_KHR:0x93b3,COMPRESSED_RGBA_ASTC_6X6_KHR:0x93b4,COMPRESSED_RGBA_ASTC_8X5_KHR:0x93b5,COMPRESSED_RGBA_ASTC_8X6_KHR:0x93b6,COMPRESSED_RGBA_ASTC_8X8_KHR:0x93b7,COMPRESSED_RGBA_ASTC_10X5_KHR:0x93b8,COMPRESSED_RGBA_ASTC_10X6_KHR:0x93b9,COMPRESSED_RGBA_ASTC_10X8_KHR:0x93ba,COMPRESSED_RGBA_ASTC_10X10_KHR:0x93bb,COMPRESSED_RGBA_ASTC_12X10_KHR:0x93bc,COMPRESSED_RGBA_ASTC_12X12_KHR:0x93bd,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:0x93d0,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:0x93d1,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:0x93d2,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:0x93d3,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:0x93d4,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:0x93d5,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:0x93d6,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:0x93d7,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:0x93d8,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:0x93d9,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:0x93da,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:0x93db,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:0x93dc,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:0x93dd,COMPRESSED_RED_RGTC1_EXT:0x8dbb,COMPRESSED_SIGNED_RED_RGTC1_EXT:0x8dbc,COMPRESSED_RED_GREEN_RGTC2_EXT:0x8dbd,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:0x8dbe,COMPRESSED_SRGB_S3TC_DXT1_EXT:0x8c4c,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:0x8c4d,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:0x8c4e,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:0x8c4f};var BROWSER_PREFIXES=['','WEBKIT_','MOZ_'];var WEBGL_EXTENSIONS={WEBGL_compressed_texture_s3tc:'dxt',WEBGL_compressed_texture_s3tc_srgb:'dxt-srgb',WEBGL_compressed_texture_etc1:'etc1',WEBGL_compressed_texture_etc:'etc2',WEBGL_compressed_texture_pvrtc:'pvrtc',WEBGL_compressed_texture_atc:'atc',WEBGL_compressed_texture_astc:'astc',EXT_texture_compression_rgtc:'rgtc'};var formats=null;function getSupportedGPUTextureFormats(gl){if(!formats){gl=gl||getWebGLContext()||undefined;formats=new Set();var _iterator17=_createForOfIteratorHelper(BROWSER_PREFIXES),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var prefix=_step17.value;for(var extension in WEBGL_EXTENSIONS){if(gl&&gl.getExtension("".concat(prefix).concat(extension))){var gpuTextureFormat=WEBGL_EXTENSIONS[extension];formats.add(gpuTextureFormat);}}}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}}return formats;}function getWebGLContext(){try{var _canvas6=document.createElement('canvas');return _canvas6.getContext('webgl');}catch(error){return null;}}var n,i,s,a,r,o,l,f;!function(t){t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB";}(n||(n={})),function(t){t[t.BASICFORMAT=0]="BASICFORMAT";}(i||(i={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC";}(s||(s={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB";}(a||(a={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2";}(r||(r={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED";}(o||(o={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA";}(l||(l={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG";}(f||(f={}));var KTX2_ID=[0xab,0x4b,0x54,0x58,0x20,0x32,0x30,0xbb,0x0d,0x0a,0x1a,0x0a];function isKTX(data){var id=new Uint8Array(data);var notKTX=id.byteLength<KTX2_ID.length||id[0]!==KTX2_ID[0]||id[1]!==KTX2_ID[1]||id[2]!==KTX2_ID[2]||id[3]!==KTX2_ID[3]||id[4]!==KTX2_ID[4]||id[5]!==KTX2_ID[5]||id[6]!==KTX2_ID[6]||id[7]!==KTX2_ID[7]||id[8]!==KTX2_ID[8]||id[9]!==KTX2_ID[9]||id[10]!==KTX2_ID[10]||id[11]!==KTX2_ID[11];return!notKTX;}var OutputFormat={etc1:{basisFormat:0,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:true},bc1:{basisFormat:2,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:true},bc5:{basisFormat:5,compressed:true},'bc7-m6-opaque-only':{basisFormat:6,compressed:true},'bc7-m5':{basisFormat:7,compressed:true},'pvrtc1-4-rgb':{basisFormat:8,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},'pvrtc1-4-rgba':{basisFormat:9,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},'astc-4x4':{basisFormat:10,compressed:true,format:GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR},'atc-rgb':{basisFormat:11,compressed:true},'atc-rgba-interpolated-alpha':{basisFormat:12,compressed:true},rgba32:{basisFormat:13,compressed:false},rgb565:{basisFormat:14,compressed:false},bgr565:{basisFormat:15,compressed:false},rgba4444:{basisFormat:16,compressed:false}};function parseBasis(_x43,_x44){return _parseBasis.apply(this,arguments);}function _parseBasis(){_parseBasis=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data,options){var fileConstructors,_yield$loadBasisTrasc,BasisFile,_fileConstructors,_yield$loadBasisTrasc2,_BasisFile;return _regeneratorRuntime().wrap(function _callee26$(_context30){while(1){switch(_context30.prev=_context30.next){case 0:if(!(options.basis.containerFormat==='auto')){_context30.next=11;break;}if(!isKTX(data)){_context30.next=6;break;}_context30.next=4;return loadBasisEncoderModule(options);case 4:fileConstructors=_context30.sent;return _context30.abrupt("return",parseKTX2File(fileConstructors.KTX2File,data,options));case 6:_context30.next=8;return loadBasisTrascoderModule(options);case 8:_yield$loadBasisTrasc=_context30.sent;BasisFile=_yield$loadBasisTrasc.BasisFile;return _context30.abrupt("return",parseBasisFile(BasisFile,data,options));case 11:_context30.t0=options.basis.module;_context30.next=_context30.t0==='encoder'?14:_context30.t0==='transcoder'?22:22;break;case 14:_context30.next=16;return loadBasisEncoderModule(options);case 16:_fileConstructors=_context30.sent;_context30.t1=options.basis.containerFormat;_context30.next=_context30.t1==='ktx2'?20:_context30.t1==='basis'?21:21;break;case 20:return _context30.abrupt("return",parseKTX2File(_fileConstructors.KTX2File,data,options));case 21:return _context30.abrupt("return",parseBasisFile(_fileConstructors.BasisFile,data,options));case 22:_context30.next=24;return loadBasisTrascoderModule(options);case 24:_yield$loadBasisTrasc2=_context30.sent;_BasisFile=_yield$loadBasisTrasc2.BasisFile;return _context30.abrupt("return",parseBasisFile(_BasisFile,data,options));case 27:case"end":return _context30.stop();}}},_callee26);}));return _parseBasis.apply(this,arguments);}function parseBasisFile(BasisFile,data,options){var basisFile=new BasisFile(new Uint8Array(data));try{if(!basisFile.startTranscoding()){throw new Error('Failed to start basis transcoding');}var imageCount=basisFile.getNumImages();var images=[];for(var imageIndex=0;imageIndex<imageCount;imageIndex++){var levelsCount=basisFile.getNumLevels(imageIndex);var levels=[];for(var levelIndex=0;levelIndex<levelsCount;levelIndex++){levels.push(transcodeImage(basisFile,imageIndex,levelIndex,options));}images.push(levels);}return images;}finally{basisFile.close();basisFile["delete"]();}}function transcodeImage(basisFile,imageIndex,levelIndex,options){var width=basisFile.getImageWidth(imageIndex,levelIndex);var height=basisFile.getImageHeight(imageIndex,levelIndex);var hasAlpha=basisFile.getHasAlpha();var _getBasisOptions=getBasisOptions(options,hasAlpha),compressed=_getBasisOptions.compressed,format=_getBasisOptions.format,basisFormat=_getBasisOptions.basisFormat;var decodedSize=basisFile.getImageTranscodedSizeInBytes(imageIndex,levelIndex,basisFormat);var decodedData=new Uint8Array(decodedSize);if(!basisFile.transcodeImage(decodedData,imageIndex,levelIndex,basisFormat,0,0)){throw new Error('failed to start Basis transcoding');}return{width:width,height:height,data:decodedData,compressed:compressed,format:format,hasAlpha:hasAlpha};}function parseKTX2File(KTX2File,data,options){var ktx2File=new KTX2File(new Uint8Array(data));try{if(!ktx2File.startTranscoding()){throw new Error('failed to start KTX2 transcoding');}var levelsCount=ktx2File.getLevels();var levels=[];for(var levelIndex=0;levelIndex<levelsCount;levelIndex++){levels.push(transcodeKTX2Image(ktx2File,levelIndex,options));break;}return[levels];}finally{ktx2File.close();ktx2File["delete"]();}}function transcodeKTX2Image(ktx2File,levelIndex,options){var _ktx2File$getImageLev=ktx2File.getImageLevelInfo(levelIndex,0,0),alphaFlag=_ktx2File$getImageLev.alphaFlag,height=_ktx2File$getImageLev.height,width=_ktx2File$getImageLev.width;var _getBasisOptions2=getBasisOptions(options,alphaFlag),compressed=_getBasisOptions2.compressed,format=_getBasisOptions2.format,basisFormat=_getBasisOptions2.basisFormat;var decodedSize=ktx2File.getImageTranscodedSizeInBytes(levelIndex,0,0,basisFormat);var decodedData=new Uint8Array(decodedSize);if(!ktx2File.transcodeImage(decodedData,levelIndex,0,0,basisFormat,0,-1,-1)){throw new Error('Failed to transcode KTX2 image');}return{width:width,height:height,data:decodedData,compressed:compressed,hasAlpha:alphaFlag,format:format};}function getBasisOptions(options,hasAlpha){var format=options&&options.basis&&options.basis.format;if(format==='auto'){format=selectSupportedBasisFormat();}if(_typeof(format)==='object'){format=hasAlpha?format.alpha:format.noAlpha;}format=format.toLowerCase();return OutputFormat[format];}function selectSupportedBasisFormat(){var supportedFormats=getSupportedGPUTextureFormats();if(supportedFormats.has('astc')){return'astc-4x4';}else if(supportedFormats.has('dxt')){return{alpha:'bc3',noAlpha:'bc1'};}else if(supportedFormats.has('pvrtc')){return{alpha:'pvrtc1-4-rgba',noAlpha:'pvrtc1-4-rgb'};}else if(supportedFormats.has('etc1')){return'etc1';}else if(supportedFormats.has('etc2')){return'etc2';}return'rgb565';}var BasisWorkerLoader={name:'Basis',id:'basis',module:'textures',version:VERSION$4,worker:true,extensions:['basis','ktx2'],mimeTypes:['application/octet-stream','image/ktx2'],tests:['sB'],binary:true,options:{basis:{format:'auto',libraryPath:'libs/',containerFormat:'auto',module:'transcoder'}}};var BasisLoader=_objectSpread(_objectSpread({},BasisWorkerLoader),{},{parse:parseBasis});var VERSION$2="3.2.6";var _parseImageNode=globalThis._parseImageNode;var IMAGE_SUPPORTED=typeof Image!=='undefined';var IMAGE_BITMAP_SUPPORTED=typeof ImageBitmap!=='undefined';var NODE_IMAGE_SUPPORTED=Boolean(_parseImageNode);var DATA_SUPPORTED=isBrowser$4?true:NODE_IMAGE_SUPPORTED;function isImageTypeSupported(type){switch(type){case'auto':return IMAGE_BITMAP_SUPPORTED||IMAGE_SUPPORTED||DATA_SUPPORTED;case'imagebitmap':return IMAGE_BITMAP_SUPPORTED;case'image':return IMAGE_SUPPORTED;case'data':return DATA_SUPPORTED;default:throw new Error("@loaders.gl/images: image ".concat(type," not supported in this environment"));}}function getDefaultImageType(){if(IMAGE_BITMAP_SUPPORTED){return'imagebitmap';}if(IMAGE_SUPPORTED){return'image';}if(DATA_SUPPORTED){return'data';}throw new Error('Install \'@loaders.gl/polyfills\' to parse images under Node.js');}function getImageType(image){var format=getImageTypeOrNull(image);if(!format){throw new Error('Not an image');}return format;}function getImageData(image){switch(getImageType(image)){case'data':return image;case'image':case'imagebitmap':var _canvas7=document.createElement('canvas');var context=_canvas7.getContext('2d');if(!context){throw new Error('getImageData');}_canvas7.width=image.width;_canvas7.height=image.height;context.drawImage(image,0,0);return context.getImageData(0,0,image.width,image.height);default:throw new Error('getImageData');}}function getImageTypeOrNull(image){if(typeof ImageBitmap!=='undefined'&&image instanceof ImageBitmap){return'imagebitmap';}if(typeof Image!=='undefined'&&image instanceof Image){return'image';}if(image&&_typeof(image)==='object'&&image.data&&image.width&&image.height){return'data';}return null;}var SVG_DATA_URL_PATTERN=/^data:image\/svg\+xml/;var SVG_URL_PATTERN=/\.svg((\?|#).*)?$/;function isSVG(url){return url&&(SVG_DATA_URL_PATTERN.test(url)||SVG_URL_PATTERN.test(url));}function getBlobOrSVGDataUrl(arrayBuffer,url){if(isSVG(url)){var textDecoder=new TextDecoder();var xmlText=textDecoder.decode(arrayBuffer);try{if(typeof unescape==='function'&&typeof encodeURIComponent==='function'){xmlText=unescape(encodeURIComponent(xmlText));}}catch(error){throw new Error(error.message);}var src="data:image/svg+xml;base64,".concat(btoa(xmlText));return src;}return getBlob(arrayBuffer,url);}function getBlob(arrayBuffer,url){if(isSVG(url)){throw new Error('SVG cannot be parsed directly to imagebitmap');}return new Blob([new Uint8Array(arrayBuffer)]);}function parseToImage(_x45,_x46,_x47){return _parseToImage.apply(this,arguments);}function _parseToImage(){_parseToImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(arrayBuffer,options,url){var blobOrDataUrl,URL,objectUrl;return _regeneratorRuntime().wrap(function _callee27$(_context31){while(1){switch(_context31.prev=_context31.next){case 0:blobOrDataUrl=getBlobOrSVGDataUrl(arrayBuffer,url);URL=self.URL||self.webkitURL;objectUrl=typeof blobOrDataUrl!=='string'&&URL.createObjectURL(blobOrDataUrl);_context31.prev=3;_context31.next=6;return loadToImage(objectUrl||blobOrDataUrl,options);case 6:return _context31.abrupt("return",_context31.sent);case 7:_context31.prev=7;if(objectUrl){URL.revokeObjectURL(objectUrl);}return _context31.finish(7);case 10:case"end":return _context31.stop();}}},_callee27,null,[[3,,7,10]]);}));return _parseToImage.apply(this,arguments);}function loadToImage(_x48,_x49){return _loadToImage.apply(this,arguments);}function _loadToImage(){_loadToImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(url,options){var image;return _regeneratorRuntime().wrap(function _callee28$(_context32){while(1){switch(_context32.prev=_context32.next){case 0:image=new Image();image.src=url;if(!(options.image&&options.image.decode&&image.decode)){_context32.next=6;break;}_context32.next=5;return image.decode();case 5:return _context32.abrupt("return",image);case 6:_context32.next=8;return new Promise(function(resolve,reject){try{image.onload=function(){return resolve(image);};image.onerror=function(err){return reject(new Error("Could not load image ".concat(url,": ").concat(err)));};}catch(error){reject(error);}});case 8:return _context32.abrupt("return",_context32.sent);case 9:case"end":return _context32.stop();}}},_callee28);}));return _loadToImage.apply(this,arguments);}var EMPTY_OBJECT={};var imagebitmapOptionsSupported=true;function parseToImageBitmap(_x50,_x51,_x52){return _parseToImageBitmap.apply(this,arguments);}function _parseToImageBitmap(){_parseToImageBitmap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(arrayBuffer,options,url){var blob,_image8,imagebitmapOptions;return _regeneratorRuntime().wrap(function _callee29$(_context33){while(1){switch(_context33.prev=_context33.next){case 0:if(!isSVG(url)){_context33.next=7;break;}_context33.next=3;return parseToImage(arrayBuffer,options,url);case 3:_image8=_context33.sent;blob=_image8;_context33.next=8;break;case 7:blob=getBlob(arrayBuffer,url);case 8:imagebitmapOptions=options&&options.imagebitmap;_context33.next=11;return safeCreateImageBitmap(blob,imagebitmapOptions);case 11:return _context33.abrupt("return",_context33.sent);case 12:case"end":return _context33.stop();}}},_callee29);}));return _parseToImageBitmap.apply(this,arguments);}function safeCreateImageBitmap(_x53){return _safeCreateImageBitmap.apply(this,arguments);}function _safeCreateImageBitmap(){_safeCreateImageBitmap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(blob){var imagebitmapOptions,_args28=arguments;return _regeneratorRuntime().wrap(function _callee30$(_context34){while(1){switch(_context34.prev=_context34.next){case 0:imagebitmapOptions=_args28.length>1&&_args28[1]!==undefined?_args28[1]:null;if(isEmptyObject(imagebitmapOptions)||!imagebitmapOptionsSupported){imagebitmapOptions=null;}if(!imagebitmapOptions){_context34.next=13;break;}_context34.prev=3;_context34.next=6;return createImageBitmap(blob,imagebitmapOptions);case 6:return _context34.abrupt("return",_context34.sent);case 9:_context34.prev=9;_context34.t0=_context34["catch"](3);console.warn(_context34.t0);imagebitmapOptionsSupported=false;case 13:_context34.next=15;return createImageBitmap(blob);case 15:return _context34.abrupt("return",_context34.sent);case 16:case"end":return _context34.stop();}}},_callee30,null,[[3,9]]);}));return _safeCreateImageBitmap.apply(this,arguments);}function isEmptyObject(object){for(var key in object||EMPTY_OBJECT){return false;}return true;}var BIG_ENDIAN=false;var LITTLE_ENDIAN=true;function getBinaryImageMetadata(binaryData){var dataView=toDataView(binaryData);return getPngMetadata(dataView)||getJpegMetadata(dataView)||getGifMetadata(dataView)||getBmpMetadata(dataView);}function getPngMetadata(binaryData){var dataView=toDataView(binaryData);var isPng=dataView.byteLength>=24&&dataView.getUint32(0,BIG_ENDIAN)===0x89504e47;if(!isPng){return null;}return{mimeType:'image/png',width:dataView.getUint32(16,BIG_ENDIAN),height:dataView.getUint32(20,BIG_ENDIAN)};}function getGifMetadata(binaryData){var dataView=toDataView(binaryData);var isGif=dataView.byteLength>=10&&dataView.getUint32(0,BIG_ENDIAN)===0x47494638;if(!isGif){return null;}return{mimeType:'image/gif',width:dataView.getUint16(6,LITTLE_ENDIAN),height:dataView.getUint16(8,LITTLE_ENDIAN)};}function getBmpMetadata(binaryData){var dataView=toDataView(binaryData);var isBmp=dataView.byteLength>=14&&dataView.getUint16(0,BIG_ENDIAN)===0x424d&&dataView.getUint32(2,LITTLE_ENDIAN)===dataView.byteLength;if(!isBmp){return null;}return{mimeType:'image/bmp',width:dataView.getUint32(18,LITTLE_ENDIAN),height:dataView.getUint32(22,LITTLE_ENDIAN)};}function getJpegMetadata(binaryData){var dataView=toDataView(binaryData);var isJpeg=dataView.byteLength>=3&&dataView.getUint16(0,BIG_ENDIAN)===0xffd8&&dataView.getUint8(2)===0xff;if(!isJpeg){return null;}var _getJpegMarkers=getJpegMarkers(),tableMarkers=_getJpegMarkers.tableMarkers,sofMarkers=_getJpegMarkers.sofMarkers;var i=2;while(i+9<dataView.byteLength){var marker=dataView.getUint16(i,BIG_ENDIAN);if(sofMarkers.has(marker)){return{mimeType:'image/jpeg',height:dataView.getUint16(i+5,BIG_ENDIAN),width:dataView.getUint16(i+7,BIG_ENDIAN)};}if(!tableMarkers.has(marker)){return null;}i+=2;i+=dataView.getUint16(i,BIG_ENDIAN);}return null;}function getJpegMarkers(){var tableMarkers=new Set([0xffdb,0xffc4,0xffcc,0xffdd,0xfffe]);for(var _i514=0xffe0;_i514<0xfff0;++_i514){tableMarkers.add(_i514);}var sofMarkers=new Set([0xffc0,0xffc1,0xffc2,0xffc3,0xffc5,0xffc6,0xffc7,0xffc9,0xffca,0xffcb,0xffcd,0xffce,0xffcf,0xffde]);return{tableMarkers:tableMarkers,sofMarkers:sofMarkers};}function toDataView(data){if(data instanceof DataView){return data;}if(ArrayBuffer.isView(data)){return new DataView(data.buffer);}if(data instanceof ArrayBuffer){return new DataView(data);}throw new Error('toDataView');}function parseToNodeImage(_x54,_x55){return _parseToNodeImage.apply(this,arguments);}function _parseToNodeImage(){_parseToNodeImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(arrayBuffer,options){var _ref29,mimeType,_parseImageNode;return _regeneratorRuntime().wrap(function _callee31$(_context35){while(1){switch(_context35.prev=_context35.next){case 0:_ref29=getBinaryImageMetadata(arrayBuffer)||{},mimeType=_ref29.mimeType;_parseImageNode=globalThis._parseImageNode;assert$5(_parseImageNode);_context35.next=5;return _parseImageNode(arrayBuffer,mimeType);case 5:return _context35.abrupt("return",_context35.sent);case 6:case"end":return _context35.stop();}}},_callee31);}));return _parseToNodeImage.apply(this,arguments);}function parseImage(_x56,_x57,_x58){return _parseImage.apply(this,arguments);}function _parseImage(){_parseImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(arrayBuffer,options,context){var imageOptions,imageType,_ref30,url,loadType,image;return _regeneratorRuntime().wrap(function _callee32$(_context36){while(1){switch(_context36.prev=_context36.next){case 0:options=options||{};imageOptions=options.image||{};imageType=imageOptions.type||'auto';_ref30=context||{},url=_ref30.url;loadType=getLoadableImageType(imageType);_context36.t0=loadType;_context36.next=_context36.t0==='imagebitmap'?8:_context36.t0==='image'?12:_context36.t0==='data'?16:20;break;case 8:_context36.next=10;return parseToImageBitmap(arrayBuffer,options,url);case 10:image=_context36.sent;return _context36.abrupt("break",21);case 12:_context36.next=14;return parseToImage(arrayBuffer,options,url);case 14:image=_context36.sent;return _context36.abrupt("break",21);case 16:_context36.next=18;return parseToNodeImage(arrayBuffer);case 18:image=_context36.sent;return _context36.abrupt("break",21);case 20:assert$5(false);case 21:if(imageType==='data'){image=getImageData(image);}return _context36.abrupt("return",image);case 23:case"end":return _context36.stop();}}},_callee32);}));return _parseImage.apply(this,arguments);}function getLoadableImageType(type){switch(type){case'auto':case'data':return getDefaultImageType();default:isImageTypeSupported(type);return type;}}var EXTENSIONS$1=['png','jpg','jpeg','gif','webp','bmp','ico','svg'];var MIME_TYPES=['image/png','image/jpeg','image/gif','image/webp','image/bmp','image/vnd.microsoft.icon','image/svg+xml'];var DEFAULT_IMAGE_LOADER_OPTIONS={image:{type:'auto',decode:true}};var ImageLoader={id:'image',module:'images',name:'Images',version:VERSION$2,mimeTypes:MIME_TYPES,extensions:EXTENSIONS$1,parse:parseImage,tests:[function(arrayBuffer){return Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)));}],options:DEFAULT_IMAGE_LOADER_OPTIONS};var NODE_FORMAT_SUPPORT=['image/png','image/jpeg','image/gif'];var mimeTypeSupported={};function _isImageFormatSupported(mimeType){if(mimeTypeSupported[mimeType]===undefined){mimeTypeSupported[mimeType]=checkFormatSupport(mimeType);}return mimeTypeSupported[mimeType];}function checkFormatSupport(mimeType){switch(mimeType){case'image/webp':return checkWebPSupport();case'image/svg':return isBrowser$4;default:if(!isBrowser$4){var _parseImageNode2=globalThis._parseImageNode;return Boolean(_parseImageNode2)&&NODE_FORMAT_SUPPORT.includes(mimeType);}return true;}}function checkWebPSupport(){if(!isBrowser$4){return false;}try{var element=document.createElement('canvas');return element.toDataURL('image/webp').indexOf('data:image/webp')===0;}catch(_unused){return false;}}function assert$1(condition,message){if(!condition){throw new Error(message||'assert failed: gltf');}}function resolveUrl(url,options){var absolute=url.startsWith('data:')||url.startsWith('http:')||url.startsWith('https:');if(absolute){return url;}var baseUrl=options.baseUri||options.uri;if(!baseUrl){throw new Error("'baseUri' must be provided to resolve relative url ".concat(url));}return baseUrl.substr(0,baseUrl.lastIndexOf('/')+1)+url;}function getTypedArrayForBufferView(json,buffers,bufferViewIndex){var bufferView=json.bufferViews[bufferViewIndex];assert$1(bufferView);var bufferIndex=bufferView.buffer;var binChunk=buffers[bufferIndex];assert$1(binChunk);var byteOffset=(bufferView.byteOffset||0)+binChunk.byteOffset;return new Uint8Array(binChunk.arrayBuffer,byteOffset,bufferView.byteLength);}var TYPES=['SCALAR','VEC2','VEC3','VEC4'];var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]];var ARRAY_TO_COMPONENT_TYPE=new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);var ATTRIBUTE_TYPE_TO_COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function getAccessorTypeFromSize(size){var type=TYPES[size-1];return type||TYPES[0];}function getComponentTypeFromArray(typedArray){var componentType=ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);if(!componentType){throw new Error('Illegal typed array');}return componentType;}function getAccessorArrayTypeAndLength(accessor,bufferView){var ArrayType=ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];var components=ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];var bytesPerComponent=ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];var length=accessor.count*components;var byteLength=accessor.count*components*bytesPerComponent;assert$1(byteLength>=0&&byteLength<=bufferView.byteLength);return{ArrayType:ArrayType,length:length,byteLength:byteLength};}var DEFAULT_GLTF_JSON={asset:{version:'2.0',generator:'loaders.gl'},buffers:[]};var GLTFScenegraph=/*#__PURE__*/function(){function GLTFScenegraph(gltf){_classCallCheck(this,GLTFScenegraph);_defineProperty(this,"gltf",void 0);_defineProperty(this,"sourceBuffers",void 0);_defineProperty(this,"byteLength",void 0);this.gltf=gltf||{json:_objectSpread({},DEFAULT_GLTF_JSON),buffers:[]};this.sourceBuffers=[];this.byteLength=0;if(this.gltf.buffers&&this.gltf.buffers[0]){this.byteLength=this.gltf.buffers[0].byteLength;this.sourceBuffers=[this.gltf.buffers[0]];}}_createClass(GLTFScenegraph,[{key:"json",get:function get(){return this.gltf.json;}},{key:"getApplicationData",value:function getApplicationData(key){var data=this.json[key];return data;}},{key:"getExtraData",value:function getExtraData(key){var extras=this.json.extras||{};return extras[key];}},{key:"getExtension",value:function getExtension(extensionName){var isExtension=this.getUsedExtensions().find(function(name){return name===extensionName;});var extensions=this.json.extensions||{};return isExtension?extensions[extensionName]||true:null;}},{key:"getRequiredExtension",value:function getRequiredExtension(extensionName){var isRequired=this.getRequiredExtensions().find(function(name){return name===extensionName;});return isRequired?this.getExtension(extensionName):null;}},{key:"getRequiredExtensions",value:function getRequiredExtensions(){return this.json.extensionsRequired||[];}},{key:"getUsedExtensions",value:function getUsedExtensions(){return this.json.extensionsUsed||[];}},{key:"getObjectExtension",value:function getObjectExtension(object,extensionName){var extensions=object.extensions||{};return extensions[extensionName];}},{key:"getScene",value:function getScene(index){return this.getObject('scenes',index);}},{key:"getNode",value:function getNode(index){return this.getObject('nodes',index);}},{key:"getSkin",value:function getSkin(index){return this.getObject('skins',index);}},{key:"getMesh",value:function getMesh(index){return this.getObject('meshes',index);}},{key:"getMaterial",value:function getMaterial(index){return this.getObject('materials',index);}},{key:"getAccessor",value:function getAccessor(index){return this.getObject('accessors',index);}},{key:"getTexture",value:function getTexture(index){return this.getObject('textures',index);}},{key:"getSampler",value:function getSampler(index){return this.getObject('samplers',index);}},{key:"getImage",value:function getImage(index){return this.getObject('images',index);}},{key:"getBufferView",value:function getBufferView(index){return this.getObject('bufferViews',index);}},{key:"getBuffer",value:function getBuffer(index){return this.getObject('buffers',index);}},{key:"getObject",value:function getObject(array,index){if(_typeof(index)==='object'){return index;}var object=this.json[array]&&this.json[array][index];if(!object){throw new Error("glTF file error: Could not find ".concat(array,"[").concat(index,"]"));}return object;}},{key:"getTypedArrayForBufferView",value:function getTypedArrayForBufferView(bufferView){bufferView=this.getBufferView(bufferView);var bufferIndex=bufferView.buffer;var binChunk=this.gltf.buffers[bufferIndex];assert$1(binChunk);var byteOffset=(bufferView.byteOffset||0)+binChunk.byteOffset;return new Uint8Array(binChunk.arrayBuffer,byteOffset,bufferView.byteLength);}},{key:"getTypedArrayForAccessor",value:function getTypedArrayForAccessor(accessor){accessor=this.getAccessor(accessor);var bufferView=this.getBufferView(accessor.bufferView);var buffer=this.getBuffer(bufferView.buffer);var arrayBuffer=buffer.data;var _getAccessorArrayType=getAccessorArrayTypeAndLength(accessor,bufferView),ArrayType=_getAccessorArrayType.ArrayType,length=_getAccessorArrayType.length;var byteOffset=bufferView.byteOffset+accessor.byteOffset;return new ArrayType(arrayBuffer,byteOffset,length);}},{key:"getTypedArrayForImageData",value:function getTypedArrayForImageData(image){image=this.getAccessor(image);var bufferView=this.getBufferView(image.bufferView);var buffer=this.getBuffer(bufferView.buffer);var arrayBuffer=buffer.data;var byteOffset=bufferView.byteOffset||0;return new Uint8Array(arrayBuffer,byteOffset,bufferView.byteLength);}},{key:"addApplicationData",value:function addApplicationData(key,data){this.json[key]=data;return this;}},{key:"addExtraData",value:function addExtraData(key,data){this.json.extras=this.json.extras||{};this.json.extras[key]=data;return this;}},{key:"addObjectExtension",value:function addObjectExtension(object,extensionName,data){object.extensions=object.extensions||{};object.extensions[extensionName]=data;this.registerUsedExtension(extensionName);return this;}},{key:"setObjectExtension",value:function setObjectExtension(object,extensionName,data){var extensions=object.extensions||{};extensions[extensionName]=data;}},{key:"removeObjectExtension",value:function removeObjectExtension(object,extensionName){var extensions=object.extensions||{};var extension=extensions[extensionName];delete extensions[extensionName];return extension;}},{key:"addExtension",value:function addExtension(extensionName){var extensionData=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};assert$1(extensionData);this.json.extensions=this.json.extensions||{};this.json.extensions[extensionName]=extensionData;this.registerUsedExtension(extensionName);return extensionData;}},{key:"addRequiredExtension",value:function addRequiredExtension(extensionName){var extensionData=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};assert$1(extensionData);this.addExtension(extensionName,extensionData);this.registerRequiredExtension(extensionName);return extensionData;}},{key:"registerUsedExtension",value:function registerUsedExtension(extensionName){this.json.extensionsUsed=this.json.extensionsUsed||[];if(!this.json.extensionsUsed.find(function(ext){return ext===extensionName;})){this.json.extensionsUsed.push(extensionName);}}},{key:"registerRequiredExtension",value:function registerRequiredExtension(extensionName){this.registerUsedExtension(extensionName);this.json.extensionsRequired=this.json.extensionsRequired||[];if(!this.json.extensionsRequired.find(function(ext){return ext===extensionName;})){this.json.extensionsRequired.push(extensionName);}}},{key:"removeExtension",value:function removeExtension(extensionName){if(this.json.extensionsRequired){this._removeStringFromArray(this.json.extensionsRequired,extensionName);}if(this.json.extensionsUsed){this._removeStringFromArray(this.json.extensionsUsed,extensionName);}if(this.json.extensions){delete this.json.extensions[extensionName];}}},{key:"setDefaultScene",value:function setDefaultScene(sceneIndex){this.json.scene=sceneIndex;}},{key:"addScene",value:function addScene(scene){var nodeIndices=scene.nodeIndices;this.json.scenes=this.json.scenes||[];this.json.scenes.push({nodes:nodeIndices});return this.json.scenes.length-1;}},{key:"addNode",value:function addNode(node){var meshIndex=node.meshIndex,matrix=node.matrix;this.json.nodes=this.json.nodes||[];var nodeData={mesh:meshIndex};if(matrix){nodeData.matrix=matrix;}this.json.nodes.push(nodeData);return this.json.nodes.length-1;}},{key:"addMesh",value:function addMesh(mesh){var attributes=mesh.attributes,indices=mesh.indices,material=mesh.material,_mesh$mode=mesh.mode,mode=_mesh$mode===void 0?4:_mesh$mode;var accessors=this._addAttributes(attributes);var glTFMesh={primitives:[{attributes:accessors,mode:mode}]};if(indices){var indicesAccessor=this._addIndices(indices);glTFMesh.primitives[0].indices=indicesAccessor;}if(Number.isFinite(material)){glTFMesh.primitives[0].material=material;}this.json.meshes=this.json.meshes||[];this.json.meshes.push(glTFMesh);return this.json.meshes.length-1;}},{key:"addPointCloud",value:function addPointCloud(attributes){var accessorIndices=this._addAttributes(attributes);var glTFMesh={primitives:[{attributes:accessorIndices,mode:0}]};this.json.meshes=this.json.meshes||[];this.json.meshes.push(glTFMesh);return this.json.meshes.length-1;}},{key:"addImage",value:function addImage(imageData,mimeTypeOpt){var metadata=getBinaryImageMetadata(imageData);var mimeType=mimeTypeOpt||(metadata===null||metadata===void 0?void 0:metadata.mimeType);var bufferViewIndex=this.addBufferView(imageData);var glTFImage={bufferView:bufferViewIndex,mimeType:mimeType};this.json.images=this.json.images||[];this.json.images.push(glTFImage);return this.json.images.length-1;}},{key:"addBufferView",value:function addBufferView(buffer){var byteLength=buffer.byteLength;assert$1(Number.isFinite(byteLength));this.sourceBuffers=this.sourceBuffers||[];this.sourceBuffers.push(buffer);var glTFBufferView={buffer:0,byteOffset:this.byteLength,byteLength:byteLength};this.byteLength+=padToNBytes(byteLength,4);this.json.bufferViews=this.json.bufferViews||[];this.json.bufferViews.push(glTFBufferView);return this.json.bufferViews.length-1;}},{key:"addAccessor",value:function addAccessor(bufferViewIndex,accessor){var glTFAccessor={bufferView:bufferViewIndex,type:getAccessorTypeFromSize(accessor.size),componentType:accessor.componentType,count:accessor.count,max:accessor.max,min:accessor.min};this.json.accessors=this.json.accessors||[];this.json.accessors.push(glTFAccessor);return this.json.accessors.length-1;}},{key:"addBinaryBuffer",value:function addBinaryBuffer(sourceBuffer){var accessor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{size:3};var bufferViewIndex=this.addBufferView(sourceBuffer);var minMax={min:accessor.min,max:accessor.max};if(!minMax.min||!minMax.max){minMax=this._getAccessorMinMax(sourceBuffer,accessor.size);}var accessorDefaults={size:accessor.size,componentType:getComponentTypeFromArray(sourceBuffer),count:Math.round(sourceBuffer.length/accessor.size),min:minMax.min,max:minMax.max};return this.addAccessor(bufferViewIndex,Object.assign(accessorDefaults,accessor));}},{key:"addTexture",value:function addTexture(texture){var imageIndex=texture.imageIndex;var glTFTexture={source:imageIndex};this.json.textures=this.json.textures||[];this.json.textures.push(glTFTexture);return this.json.textures.length-1;}},{key:"addMaterial",value:function addMaterial(pbrMaterialInfo){this.json.materials=this.json.materials||[];this.json.materials.push(pbrMaterialInfo);return this.json.materials.length-1;}},{key:"createBinaryChunk",value:function createBinaryChunk(){var _this$json,_this$json$buffers;this.gltf.buffers=[];var totalByteLength=this.byteLength;var arrayBuffer=new ArrayBuffer(totalByteLength);var targetArray=new Uint8Array(arrayBuffer);var dstByteOffset=0;var _iterator18=_createForOfIteratorHelper(this.sourceBuffers||[]),_step18;try{for(_iterator18.s();!(_step18=_iterator18.n()).done;){var sourceBuffer=_step18.value;dstByteOffset=copyToArray(sourceBuffer,targetArray,dstByteOffset);}}catch(err){_iterator18.e(err);}finally{_iterator18.f();}if((_this$json=this.json)!==null&&_this$json!==void 0&&(_this$json$buffers=_this$json.buffers)!==null&&_this$json$buffers!==void 0&&_this$json$buffers[0]){this.json.buffers[0].byteLength=totalByteLength;}else{this.json.buffers=[{byteLength:totalByteLength}];}this.gltf.binary=arrayBuffer;this.sourceBuffers=[arrayBuffer];}},{key:"_removeStringFromArray",value:function _removeStringFromArray(array,string){var found=true;while(found){var index=array.indexOf(string);if(index>-1){array.splice(index,1);}else{found=false;}}}},{key:"_addAttributes",value:function _addAttributes(){var attributes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var result={};for(var attributeKey in attributes){var attributeData=attributes[attributeKey];var attrName=this._getGltfAttributeName(attributeKey);var accessor=this.addBinaryBuffer(attributeData.value,attributeData);result[attrName]=accessor;}return result;}},{key:"_addIndices",value:function _addIndices(indices){return this.addBinaryBuffer(indices,{size:1});}},{key:"_getGltfAttributeName",value:function _getGltfAttributeName(attributeName){switch(attributeName.toLowerCase()){case'position':case'positions':case'vertices':return'POSITION';case'normal':case'normals':return'NORMAL';case'color':case'colors':return'COLOR_0';case'texcoord':case'texcoords':return'TEXCOORD_0';default:return attributeName;}}},{key:"_getAccessorMinMax",value:function _getAccessorMinMax(buffer,size){var result={min:null,max:null};if(buffer.length<size){return result;}result.min=[];result.max=[];var initValues=buffer.subarray(0,size);var _iterator19=_createForOfIteratorHelper(initValues),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var value=_step19.value;result.min.push(value);result.max.push(value);}}catch(err){_iterator19.e(err);}finally{_iterator19.f();}for(var index=size;index<buffer.length;index+=size){for(var componentIndex=0;componentIndex<size;componentIndex++){result.min[0+componentIndex]=Math.min(result.min[0+componentIndex],buffer[index+componentIndex]);result.max[0+componentIndex]=Math.max(result.max[0+componentIndex],buffer[index+componentIndex]);}}return result;}}]);return GLTFScenegraph;}();var wasm_base='B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB';var wasm_simd='B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB';var detector=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);var wasmpack=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);var FILTERS={0:'',1:'meshopt_decodeFilterOct',2:'meshopt_decodeFilterQuat',3:'meshopt_decodeFilterExp',NONE:'',OCTAHEDRAL:'meshopt_decodeFilterOct',QUATERNION:'meshopt_decodeFilterQuat',EXPONENTIAL:'meshopt_decodeFilterExp'};var DECODERS={0:'meshopt_decodeVertexBuffer',1:'meshopt_decodeIndexBuffer',2:'meshopt_decodeIndexSequence',ATTRIBUTES:'meshopt_decodeVertexBuffer',TRIANGLES:'meshopt_decodeIndexBuffer',INDICES:'meshopt_decodeIndexSequence'};function meshoptDecodeGltfBuffer(_x59,_x60,_x61,_x62,_x63){return _meshoptDecodeGltfBuffer.apply(this,arguments);}function _meshoptDecodeGltfBuffer(){_meshoptDecodeGltfBuffer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(target,count,size,source,mode){var filter,instance,_args31=arguments;return _regeneratorRuntime().wrap(function _callee33$(_context37){while(1){switch(_context37.prev=_context37.next){case 0:filter=_args31.length>5&&_args31[5]!==undefined?_args31[5]:'NONE';_context37.next=3;return loadWasmInstance();case 3:instance=_context37.sent;decode$5(instance,instance.exports[DECODERS[mode]],target,count,size,source,instance.exports[FILTERS[filter||'NONE']]);case 5:case"end":return _context37.stop();}}},_callee33);}));return _meshoptDecodeGltfBuffer.apply(this,arguments);}var wasmPromise;function loadWasmInstance(){return _loadWasmInstance.apply(this,arguments);}function _loadWasmInstance(){_loadWasmInstance=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(){return _regeneratorRuntime().wrap(function _callee34$(_context38){while(1){switch(_context38.prev=_context38.next){case 0:if(!wasmPromise){wasmPromise=loadWasmModule();}return _context38.abrupt("return",wasmPromise);case 2:case"end":return _context38.stop();}}},_callee34);}));return _loadWasmInstance.apply(this,arguments);}function loadWasmModule(){return _loadWasmModule.apply(this,arguments);}function _loadWasmModule(){_loadWasmModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(){var wasm,result;return _regeneratorRuntime().wrap(function _callee35$(_context39){while(1){switch(_context39.prev=_context39.next){case 0:wasm=wasm_base;if(WebAssembly.validate(detector)){wasm=wasm_simd;console.log('Warning: meshopt_decoder is using experimental SIMD support');}_context39.next=4;return WebAssembly.instantiate(unpack(wasm),{});case 4:result=_context39.sent;_context39.next=7;return result.instance.exports.__wasm_call_ctors();case 7:return _context39.abrupt("return",result.instance);case 8:case"end":return _context39.stop();}}},_callee35);}));return _loadWasmModule.apply(this,arguments);}function unpack(data){var result=new Uint8Array(data.length);for(var _i515=0;_i515<data.length;++_i515){var ch=data.charCodeAt(_i515);result[_i515]=ch>96?ch-71:ch>64?ch-65:ch>47?ch+4:ch>46?63:62;}var write=0;for(var _i516=0;_i516<data.length;++_i516){result[write++]=result[_i516]<60?wasmpack[result[_i516]]:(result[_i516]-60)*64+result[++_i516];}return result.buffer.slice(0,write);}function decode$5(instance,fun,target,count,size,source,filter){var sbrk=instance.exports.sbrk;var count4=count+3&~3;var tp=sbrk(count4*size);var sp=sbrk(source.length);var heap=new Uint8Array(instance.exports.memory.buffer);heap.set(source,sp);var res=fun(tp,count,size,sp,source.length);if(res===0&&filter){filter(tp,count4,size);}target.set(heap.subarray(tp,tp+count*size));sbrk(tp-sbrk(0));if(res!==0){throw new Error("Malformed buffer data: ".concat(res));}}var EXT_MESHOPT_COMPRESSION='EXT_meshopt_compression';var name$6=EXT_MESHOPT_COMPRESSION;function decode$4(_x64,_x65){return _decode$.apply(this,arguments);}function _decode$(){_decode$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(gltfData,options){var _options$gltf,scenegraph,promises,_iterator49,_step49,bufferViewIndex;return _regeneratorRuntime().wrap(function _callee36$(_context40){while(1){switch(_context40.prev=_context40.next){case 0:scenegraph=new GLTFScenegraph(gltfData);if(options!==null&&options!==void 0&&(_options$gltf=options.gltf)!==null&&_options$gltf!==void 0&&_options$gltf.decompressMeshes){_context40.next=3;break;}return _context40.abrupt("return");case 3:promises=[];_iterator49=_createForOfIteratorHelper(gltfData.json.bufferViews||[]);try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){bufferViewIndex=_step49.value;promises.push(decodeMeshoptBufferView(scenegraph,bufferViewIndex));}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}_context40.next=8;return Promise.all(promises);case 8:scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);case 9:case"end":return _context40.stop();}}},_callee36);}));return _decode$.apply(this,arguments);}function decodeMeshoptBufferView(_x66,_x67){return _decodeMeshoptBufferView.apply(this,arguments);}function _decodeMeshoptBufferView(){_decodeMeshoptBufferView=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(scenegraph,bufferView){var meshoptExtension,_meshoptExtension$byt,byteOffset,_meshoptExtension$byt2,byteLength,byteStride,count,mode,_meshoptExtension$fil,filter,bufferIndex,buffer,source,result;return _regeneratorRuntime().wrap(function _callee37$(_context41){while(1){switch(_context41.prev=_context41.next){case 0:meshoptExtension=scenegraph.getObjectExtension(bufferView,EXT_MESHOPT_COMPRESSION);if(!meshoptExtension){_context41.next=9;break;}_meshoptExtension$byt=meshoptExtension.byteOffset,byteOffset=_meshoptExtension$byt===void 0?0:_meshoptExtension$byt,_meshoptExtension$byt2=meshoptExtension.byteLength,byteLength=_meshoptExtension$byt2===void 0?0:_meshoptExtension$byt2,byteStride=meshoptExtension.byteStride,count=meshoptExtension.count,mode=meshoptExtension.mode,_meshoptExtension$fil=meshoptExtension.filter,filter=_meshoptExtension$fil===void 0?'NONE':_meshoptExtension$fil,bufferIndex=meshoptExtension.buffer;buffer=scenegraph.gltf.buffers[bufferIndex];source=new Uint8Array(buffer.arrayBuffer,buffer.byteOffset+byteOffset,byteLength);result=new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,bufferView.byteOffset,bufferView.byteLength);_context41.next=8;return meshoptDecodeGltfBuffer(result,count,byteStride,source,mode,filter);case 8:return _context41.abrupt("return",result);case 9:return _context41.abrupt("return",null);case 10:case"end":return _context41.stop();}}},_callee37);}));return _decodeMeshoptBufferView.apply(this,arguments);}var EXT_meshopt_compression=/*#__PURE__*/Object.freeze({__proto__:null,name:name$6,decode:decode$4});var EXT_TEXTURE_WEBP='EXT_texture_webp';var name$5=EXT_TEXTURE_WEBP;function preprocess$3(gltfData,options){var scenegraph=new GLTFScenegraph(gltfData);if(!_isImageFormatSupported('image/webp')){if(scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)){throw new Error("gltf: Required extension ".concat(EXT_TEXTURE_WEBP," not supported by browser"));}return;}var json=scenegraph.json;var _iterator20=_createForOfIteratorHelper(json.textures||[]),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var texture=_step20.value;var extension=scenegraph.getObjectExtension(texture,EXT_TEXTURE_WEBP);if(extension){texture.source=extension.source;}scenegraph.removeObjectExtension(texture,EXT_TEXTURE_WEBP);}}catch(err){_iterator20.e(err);}finally{_iterator20.f();}scenegraph.removeExtension(EXT_TEXTURE_WEBP);}var EXT_texture_webp=/*#__PURE__*/Object.freeze({__proto__:null,name:name$5,preprocess:preprocess$3});var KHR_TEXTURE_BASISU='KHR_texture_basisu';var name$4=KHR_TEXTURE_BASISU;function preprocess$2(gltfData,options){var scene=new GLTFScenegraph(gltfData);var json=scene.json;var _iterator21=_createForOfIteratorHelper(json.textures||[]),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;){var texture=_step21.value;var extension=scene.getObjectExtension(texture,KHR_TEXTURE_BASISU);if(extension){texture.source=extension.source;}scene.removeObjectExtension(texture,KHR_TEXTURE_BASISU);}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}scene.removeExtension(KHR_TEXTURE_BASISU);}var KHR_texture_basisu=/*#__PURE__*/Object.freeze({__proto__:null,name:name$4,preprocess:preprocess$2});var VERSION$1="3.2.6";var DEFAULT_DRACO_OPTIONS={draco:{decoderType:(typeof WebAssembly==="undefined"?"undefined":_typeof(WebAssembly))==='object'?'wasm':'js',libraryPath:'libs/',extraAttributes:{},attributeNameEntry:undefined}};var DracoLoader$1={name:'Draco',id:'draco',module:'draco',shapes:['mesh'],version:VERSION$1,worker:true,extensions:['drc'],mimeTypes:['application/octet-stream'],binary:true,tests:['DRACO'],options:DEFAULT_DRACO_OPTIONS};function getMeshBoundingBox(attributes){var minX=Infinity;var minY=Infinity;var minZ=Infinity;var maxX=-Infinity;var maxY=-Infinity;var maxZ=-Infinity;var positions=attributes.POSITION?attributes.POSITION.value:[];var len=positions&&positions.length;for(var _i517=0;_i517<len;_i517+=3){var x=positions[_i517];var y=positions[_i517+1];var _z4=positions[_i517+2];minX=x<minX?x:minX;minY=y<minY?y:minY;minZ=_z4<minZ?_z4:minZ;maxX=x>maxX?x:maxX;maxY=y>maxY?y:maxY;maxZ=_z4>maxZ?_z4:maxZ;}return[[minX,minY,minZ],[maxX,maxY,maxZ]];}function assert(condition,message){if(!condition){throw new Error(message||'loader assertion failed.');}}var Schema=/*#__PURE__*/function(){function Schema(fields,metadata){_classCallCheck(this,Schema);_defineProperty(this,"fields",void 0);_defineProperty(this,"metadata",void 0);assert(Array.isArray(fields));checkNames(fields);this.fields=fields;this.metadata=metadata||new Map();}_createClass(Schema,[{key:"compareTo",value:function compareTo(other){if(this.metadata!==other.metadata){return false;}if(this.fields.length!==other.fields.length){return false;}for(var _i518=0;_i518<this.fields.length;++_i518){if(!this.fields[_i518].compareTo(other.fields[_i518])){return false;}}return true;}},{key:"select",value:function select(){var nameMap=Object.create(null);for(var _len106=arguments.length,columnNames=new Array(_len106),_key11=0;_key11<_len106;_key11++){columnNames[_key11]=arguments[_key11];}for(var _i519=0,_columnNames=columnNames;_i519<_columnNames.length;_i519++){var _name6=_columnNames[_i519];nameMap[_name6]=true;}var selectedFields=this.fields.filter(function(field){return nameMap[field.name];});return new Schema(selectedFields,this.metadata);}},{key:"selectAt",value:function selectAt(){var _this124=this;for(var _len107=arguments.length,columnIndices=new Array(_len107),_key12=0;_key12<_len107;_key12++){columnIndices[_key12]=arguments[_key12];}var selectedFields=columnIndices.map(function(index){return _this124.fields[index];}).filter(Boolean);return new Schema(selectedFields,this.metadata);}},{key:"assign",value:function assign(schemaOrFields){var fields;var metadata=this.metadata;if(schemaOrFields instanceof Schema){var otherSchema=schemaOrFields;fields=otherSchema.fields;metadata=mergeMaps(mergeMaps(new Map(),this.metadata),otherSchema.metadata);}else{fields=schemaOrFields;}var fieldMap=Object.create(null);var _iterator22=_createForOfIteratorHelper(this.fields),_step22;try{for(_iterator22.s();!(_step22=_iterator22.n()).done;){var field=_step22.value;fieldMap[field.name]=field;}}catch(err){_iterator22.e(err);}finally{_iterator22.f();}var _iterator23=_createForOfIteratorHelper(fields),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var _field=_step23.value;fieldMap[_field.name]=_field;}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}var mergedFields=Object.values(fieldMap);return new Schema(mergedFields,metadata);}}]);return Schema;}();function checkNames(fields){var usedNames={};var _iterator24=_createForOfIteratorHelper(fields),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var field=_step24.value;if(usedNames[field.name]){console.warn('Schema: duplicated field name',field.name,field);}usedNames[field.name]=true;}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}}function mergeMaps(m1,m2){return new Map([].concat(_toConsumableArray(m1||new Map()),_toConsumableArray(m2||new Map())));}var Field=/*#__PURE__*/function(){function Field(name,type){var nullable=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var metadata=arguments.length>3&&arguments[3]!==undefined?arguments[3]:new Map();_classCallCheck(this,Field);_defineProperty(this,"name",void 0);_defineProperty(this,"type",void 0);_defineProperty(this,"nullable",void 0);_defineProperty(this,"metadata",void 0);this.name=name;this.type=type;this.nullable=nullable;this.metadata=metadata;}_createClass(Field,[{key:"typeId",get:function get(){return this.type&&this.type.typeId;}},{key:"clone",value:function clone(){return new Field(this.name,this.type,this.nullable,this.metadata);}},{key:"compareTo",value:function compareTo(other){return this.name===other.name&&this.type===other.type&&this.nullable===other.nullable&&this.metadata===other.metadata;}},{key:"toString",value:function toString(){return"".concat(this.type).concat(this.nullable?', nullable':'').concat(this.metadata?", metadata: ".concat(this.metadata):'');}}]);return Field;}();var Type;(function(Type){Type[Type["NONE"]=0]="NONE";Type[Type["Null"]=1]="Null";Type[Type["Int"]=2]="Int";Type[Type["Float"]=3]="Float";Type[Type["Binary"]=4]="Binary";Type[Type["Utf8"]=5]="Utf8";Type[Type["Bool"]=6]="Bool";Type[Type["Decimal"]=7]="Decimal";Type[Type["Date"]=8]="Date";Type[Type["Time"]=9]="Time";Type[Type["Timestamp"]=10]="Timestamp";Type[Type["Interval"]=11]="Interval";Type[Type["List"]=12]="List";Type[Type["Struct"]=13]="Struct";Type[Type["Union"]=14]="Union";Type[Type["FixedSizeBinary"]=15]="FixedSizeBinary";Type[Type["FixedSizeList"]=16]="FixedSizeList";Type[Type["Map"]=17]="Map";Type[Type["Dictionary"]=-1]="Dictionary";Type[Type["Int8"]=-2]="Int8";Type[Type["Int16"]=-3]="Int16";Type[Type["Int32"]=-4]="Int32";Type[Type["Int64"]=-5]="Int64";Type[Type["Uint8"]=-6]="Uint8";Type[Type["Uint16"]=-7]="Uint16";Type[Type["Uint32"]=-8]="Uint32";Type[Type["Uint64"]=-9]="Uint64";Type[Type["Float16"]=-10]="Float16";Type[Type["Float32"]=-11]="Float32";Type[Type["Float64"]=-12]="Float64";Type[Type["DateDay"]=-13]="DateDay";Type[Type["DateMillisecond"]=-14]="DateMillisecond";Type[Type["TimestampSecond"]=-15]="TimestampSecond";Type[Type["TimestampMillisecond"]=-16]="TimestampMillisecond";Type[Type["TimestampMicrosecond"]=-17]="TimestampMicrosecond";Type[Type["TimestampNanosecond"]=-18]="TimestampNanosecond";Type[Type["TimeSecond"]=-19]="TimeSecond";Type[Type["TimeMillisecond"]=-20]="TimeMillisecond";Type[Type["TimeMicrosecond"]=-21]="TimeMicrosecond";Type[Type["TimeNanosecond"]=-22]="TimeNanosecond";Type[Type["DenseUnion"]=-23]="DenseUnion";Type[Type["SparseUnion"]=-24]="SparseUnion";Type[Type["IntervalDayTime"]=-25]="IntervalDayTime";Type[Type["IntervalYearMonth"]=-26]="IntervalYearMonth";})(Type||(Type={}));var _Symbol$toStringTag,_Symbol$toStringTag2,_Symbol$toStringTag7;var DataType=/*#__PURE__*/function(){function DataType(){_classCallCheck(this,DataType);}_createClass(DataType,[{key:"typeId",get:function get(){return Type.NONE;}},{key:"compareTo",value:function compareTo(other){return this===other;}}],[{key:"isNull",value:function isNull(x){return x&&x.typeId===Type.Null;}},{key:"isInt",value:function isInt(x){return x&&x.typeId===Type.Int;}},{key:"isFloat",value:function isFloat(x){return x&&x.typeId===Type.Float;}},{key:"isBinary",value:function isBinary(x){return x&&x.typeId===Type.Binary;}},{key:"isUtf8",value:function isUtf8(x){return x&&x.typeId===Type.Utf8;}},{key:"isBool",value:function isBool(x){return x&&x.typeId===Type.Bool;}},{key:"isDecimal",value:function isDecimal(x){return x&&x.typeId===Type.Decimal;}},{key:"isDate",value:function isDate(x){return x&&x.typeId===Type.Date;}},{key:"isTime",value:function isTime(x){return x&&x.typeId===Type.Time;}},{key:"isTimestamp",value:function isTimestamp(x){return x&&x.typeId===Type.Timestamp;}},{key:"isInterval",value:function isInterval(x){return x&&x.typeId===Type.Interval;}},{key:"isList",value:function isList(x){return x&&x.typeId===Type.List;}},{key:"isStruct",value:function isStruct(x){return x&&x.typeId===Type.Struct;}},{key:"isUnion",value:function isUnion(x){return x&&x.typeId===Type.Union;}},{key:"isFixedSizeBinary",value:function isFixedSizeBinary(x){return x&&x.typeId===Type.FixedSizeBinary;}},{key:"isFixedSizeList",value:function isFixedSizeList(x){return x&&x.typeId===Type.FixedSizeList;}},{key:"isMap",value:function isMap(x){return x&&x.typeId===Type.Map;}},{key:"isDictionary",value:function isDictionary(x){return x&&x.typeId===Type.Dictionary;}}]);return DataType;}();_Symbol$toStringTag=Symbol.toStringTag;var Int=/*#__PURE__*/function(_DataType,_Symbol$toStringTag3){_inherits(Int,_DataType);var _super147=_createSuper(Int);function Int(isSigned,bitWidth){var _this125;_classCallCheck(this,Int);_this125=_super147.call(this);_defineProperty(_assertThisInitialized(_this125),"isSigned",void 0);_defineProperty(_assertThisInitialized(_this125),"bitWidth",void 0);_this125.isSigned=isSigned;_this125.bitWidth=bitWidth;return _this125;}_createClass(Int,[{key:"typeId",get:function get(){return Type.Int;}},{key:_Symbol$toStringTag3,get:function get(){return'Int';}},{key:"toString",value:function toString(){return"".concat(this.isSigned?'I':'Ui',"nt").concat(this.bitWidth);}}]);return Int;}(DataType,_Symbol$toStringTag);var Int8=/*#__PURE__*/function(_Int){_inherits(Int8,_Int);var _super148=_createSuper(Int8);function Int8(){_classCallCheck(this,Int8);return _super148.call(this,true,8);}return _createClass(Int8);}(Int);var Int16=/*#__PURE__*/function(_Int2){_inherits(Int16,_Int2);var _super149=_createSuper(Int16);function Int16(){_classCallCheck(this,Int16);return _super149.call(this,true,16);}return _createClass(Int16);}(Int);var Int32=/*#__PURE__*/function(_Int3){_inherits(Int32,_Int3);var _super150=_createSuper(Int32);function Int32(){_classCallCheck(this,Int32);return _super150.call(this,true,32);}return _createClass(Int32);}(Int);var Uint8=/*#__PURE__*/function(_Int4){_inherits(Uint8,_Int4);var _super151=_createSuper(Uint8);function Uint8(){_classCallCheck(this,Uint8);return _super151.call(this,false,8);}return _createClass(Uint8);}(Int);var Uint16=/*#__PURE__*/function(_Int5){_inherits(Uint16,_Int5);var _super152=_createSuper(Uint16);function Uint16(){_classCallCheck(this,Uint16);return _super152.call(this,false,16);}return _createClass(Uint16);}(Int);var Uint32=/*#__PURE__*/function(_Int6){_inherits(Uint32,_Int6);var _super153=_createSuper(Uint32);function Uint32(){_classCallCheck(this,Uint32);return _super153.call(this,false,32);}return _createClass(Uint32);}(Int);var Precision={HALF:16,SINGLE:32,DOUBLE:64};_Symbol$toStringTag2=Symbol.toStringTag;var Float=/*#__PURE__*/function(_DataType2,_Symbol$toStringTag4){_inherits(Float,_DataType2);var _super154=_createSuper(Float);function Float(precision){var _this126;_classCallCheck(this,Float);_this126=_super154.call(this);_defineProperty(_assertThisInitialized(_this126),"precision",void 0);_this126.precision=precision;return _this126;}_createClass(Float,[{key:"typeId",get:function get(){return Type.Float;}},{key:_Symbol$toStringTag4,get:function get(){return'Float';}},{key:"toString",value:function toString(){return"Float".concat(this.precision);}}]);return Float;}(DataType,_Symbol$toStringTag2);var Float32=/*#__PURE__*/function(_Float){_inherits(Float32,_Float);var _super155=_createSuper(Float32);function Float32(){_classCallCheck(this,Float32);return _super155.call(this,Precision.SINGLE);}return _createClass(Float32);}(Float);var Float64=/*#__PURE__*/function(_Float2){_inherits(Float64,_Float2);var _super156=_createSuper(Float64);function Float64(){_classCallCheck(this,Float64);return _super156.call(this,Precision.DOUBLE);}return _createClass(Float64);}(Float);_Symbol$toStringTag7=Symbol.toStringTag;var FixedSizeList=/*#__PURE__*/function(_DataType3,_Symbol$toStringTag5){_inherits(FixedSizeList,_DataType3);var _super157=_createSuper(FixedSizeList);function FixedSizeList(listSize,child){var _this127;_classCallCheck(this,FixedSizeList);_this127=_super157.call(this);_defineProperty(_assertThisInitialized(_this127),"listSize",void 0);_defineProperty(_assertThisInitialized(_this127),"children",void 0);_this127.listSize=listSize;_this127.children=[child];return _this127;}_createClass(FixedSizeList,[{key:"typeId",get:function get(){return Type.FixedSizeList;}},{key:"valueType",get:function get(){return this.children[0].type;}},{key:"valueField",get:function get(){return this.children[0];}},{key:_Symbol$toStringTag5,get:function get(){return'FixedSizeList';}},{key:"toString",value:function toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">");}}]);return FixedSizeList;}(DataType,_Symbol$toStringTag7);function getArrowTypeFromTypedArray(array){switch(array.constructor){case Int8Array:return new Int8();case Uint8Array:return new Uint8();case Int16Array:return new Int16();case Uint16Array:return new Uint16();case Int32Array:return new Int32();case Uint32Array:return new Uint32();case Float32Array:return new Float32();case Float64Array:return new Float64();default:throw new Error('array type not supported');}}function deduceMeshField(attributeName,attribute,optionalMetadata){var type=getArrowTypeFromTypedArray(attribute.value);var metadata=optionalMetadata?optionalMetadata:makeMeshAttributeMetadata(attribute);var field=new Field(attributeName,new FixedSizeList(attribute.size,new Field('value',type)),false,metadata);return field;}function makeMeshAttributeMetadata(attribute){var result=new Map();if('byteOffset'in attribute){result.set('byteOffset',attribute.byteOffset.toString(10));}if('byteStride'in attribute){result.set('byteStride',attribute.byteStride.toString(10));}if('normalized'in attribute){result.set('normalized',attribute.normalized.toString());}return result;}function getDracoSchema(attributes,loaderData,indices){var metadataMap=makeMetadata(loaderData.metadata);var fields=[];var namedLoaderDataAttributes=transformAttributesLoaderData(loaderData.attributes);for(var attributeName in attributes){var attribute=attributes[attributeName];var field=getArrowFieldFromAttribute(attributeName,attribute,namedLoaderDataAttributes[attributeName]);fields.push(field);}if(indices){var indicesField=getArrowFieldFromAttribute('indices',indices);fields.push(indicesField);}return new Schema(fields,metadataMap);}function transformAttributesLoaderData(loaderData){var result={};for(var key in loaderData){var dracoAttribute=loaderData[key];result[dracoAttribute.name||'undefined']=dracoAttribute;}return result;}function getArrowFieldFromAttribute(attributeName,attribute,loaderData){var metadataMap=loaderData?makeMetadata(loaderData.metadata):undefined;var field=deduceMeshField(attributeName,attribute,metadataMap);return field;}function makeMetadata(metadata){var metadataMap=new Map();for(var key in metadata){metadataMap.set("".concat(key,".string"),JSON.stringify(metadata[key]));}return metadataMap;}var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP={POSITION:'POSITION',NORMAL:'NORMAL',COLOR:'COLOR_0',TEX_COORD:'TEXCOORD_0'};var DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};var INDEX_ITEM_SIZE=4;var DracoParser=/*#__PURE__*/function(){function DracoParser(draco){_classCallCheck(this,DracoParser);_defineProperty(this,"draco",void 0);_defineProperty(this,"decoder",void 0);_defineProperty(this,"metadataQuerier",void 0);this.draco=draco;this.decoder=new this.draco.Decoder();this.metadataQuerier=new this.draco.MetadataQuerier();}_createClass(DracoParser,[{key:"destroy",value:function destroy(){this.draco.destroy(this.decoder);this.draco.destroy(this.metadataQuerier);}},{key:"parseSync",value:function parseSync(arrayBuffer){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var buffer=new this.draco.DecoderBuffer();buffer.Init(new Int8Array(arrayBuffer),arrayBuffer.byteLength);this._disableAttributeTransforms(options);var geometry_type=this.decoder.GetEncodedGeometryType(buffer);var dracoGeometry=geometry_type===this.draco.TRIANGULAR_MESH?new this.draco.Mesh():new this.draco.PointCloud();try{var dracoStatus;switch(geometry_type){case this.draco.TRIANGULAR_MESH:dracoStatus=this.decoder.DecodeBufferToMesh(buffer,dracoGeometry);break;case this.draco.POINT_CLOUD:dracoStatus=this.decoder.DecodeBufferToPointCloud(buffer,dracoGeometry);break;default:throw new Error('DRACO: Unknown geometry type.');}if(!dracoStatus.ok()||!dracoGeometry.ptr){var message="DRACO decompression failed: ".concat(dracoStatus.error_msg());throw new Error(message);}var loaderData=this._getDracoLoaderData(dracoGeometry,geometry_type,options);var geometry=this._getMeshData(dracoGeometry,loaderData,options);var boundingBox=getMeshBoundingBox(geometry.attributes);var schema=getDracoSchema(geometry.attributes,loaderData,geometry.indices);var data=_objectSpread(_objectSpread({loader:'draco',loaderData:loaderData,header:{vertexCount:dracoGeometry.num_points(),boundingBox:boundingBox}},geometry),{},{schema:schema});return data;}finally{this.draco.destroy(buffer);if(dracoGeometry){this.draco.destroy(dracoGeometry);}}}},{key:"_getDracoLoaderData",value:function _getDracoLoaderData(dracoGeometry,geometry_type,options){var metadata=this._getTopLevelMetadata(dracoGeometry);var attributes=this._getDracoAttributes(dracoGeometry,options);return{geometry_type:geometry_type,num_attributes:dracoGeometry.num_attributes(),num_points:dracoGeometry.num_points(),num_faces:dracoGeometry instanceof this.draco.Mesh?dracoGeometry.num_faces():0,metadata:metadata,attributes:attributes};}},{key:"_getDracoAttributes",value:function _getDracoAttributes(dracoGeometry,options){var dracoAttributes={};for(var attributeId=0;attributeId<dracoGeometry.num_attributes();attributeId++){var dracoAttribute=this.decoder.GetAttribute(dracoGeometry,attributeId);var metadata=this._getAttributeMetadata(dracoGeometry,attributeId);dracoAttributes[dracoAttribute.unique_id()]={unique_id:dracoAttribute.unique_id(),attribute_type:dracoAttribute.attribute_type(),data_type:dracoAttribute.data_type(),num_components:dracoAttribute.num_components(),byte_offset:dracoAttribute.byte_offset(),byte_stride:dracoAttribute.byte_stride(),normalized:dracoAttribute.normalized(),attribute_index:attributeId,metadata:metadata};var quantization=this._getQuantizationTransform(dracoAttribute,options);if(quantization){dracoAttributes[dracoAttribute.unique_id()].quantization_transform=quantization;}var octahedron=this._getOctahedronTransform(dracoAttribute,options);if(octahedron){dracoAttributes[dracoAttribute.unique_id()].octahedron_transform=octahedron;}}return dracoAttributes;}},{key:"_getMeshData",value:function _getMeshData(dracoGeometry,loaderData,options){var attributes=this._getMeshAttributes(loaderData,dracoGeometry,options);var positionAttribute=attributes.POSITION;if(!positionAttribute){throw new Error('DRACO: No position attribute found.');}if(dracoGeometry instanceof this.draco.Mesh){switch(options.topology){case'triangle-strip':return{topology:'triangle-strip',mode:4,attributes:attributes,indices:{value:this._getTriangleStripIndices(dracoGeometry),size:1}};case'triangle-list':default:return{topology:'triangle-list',mode:5,attributes:attributes,indices:{value:this._getTriangleListIndices(dracoGeometry),size:1}};}}return{topology:'point-list',mode:0,attributes:attributes};}},{key:"_getMeshAttributes",value:function _getMeshAttributes(loaderData,dracoGeometry,options){var attributes={};for(var _i520=0,_Object$values=Object.values(loaderData.attributes);_i520<_Object$values.length;_i520++){var loaderAttribute=_Object$values[_i520];var attributeName=this._deduceAttributeName(loaderAttribute,options);loaderAttribute.name=attributeName;var _this$_getAttributeVa=this._getAttributeValues(dracoGeometry,loaderAttribute),value=_this$_getAttributeVa.value,size=_this$_getAttributeVa.size;attributes[attributeName]={value:value,size:size,byteOffset:loaderAttribute.byte_offset,byteStride:loaderAttribute.byte_stride,normalized:loaderAttribute.normalized};}return attributes;}},{key:"_getTriangleListIndices",value:function _getTriangleListIndices(dracoGeometry){var numFaces=dracoGeometry.num_faces();var numIndices=numFaces*3;var byteLength=numIndices*INDEX_ITEM_SIZE;var ptr=this.draco._malloc(byteLength);try{this.decoder.GetTrianglesUInt32Array(dracoGeometry,byteLength,ptr);return new Uint32Array(this.draco.HEAPF32.buffer,ptr,numIndices).slice();}finally{this.draco._free(ptr);}}},{key:"_getTriangleStripIndices",value:function _getTriangleStripIndices(dracoGeometry){var dracoArray=new this.draco.DracoInt32Array();try{this.decoder.GetTriangleStripsFromMesh(dracoGeometry,dracoArray);return getUint32Array(dracoArray);}finally{this.draco.destroy(dracoArray);}}},{key:"_getAttributeValues",value:function _getAttributeValues(dracoGeometry,attribute){var TypedArrayCtor=DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];var numComponents=attribute.num_components;var numPoints=dracoGeometry.num_points();var numValues=numPoints*numComponents;var byteLength=numValues*TypedArrayCtor.BYTES_PER_ELEMENT;var dataType=getDracoDataType(this.draco,TypedArrayCtor);var value;var ptr=this.draco._malloc(byteLength);try{var dracoAttribute=this.decoder.GetAttribute(dracoGeometry,attribute.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry,dracoAttribute,dataType,byteLength,ptr);value=new TypedArrayCtor(this.draco.HEAPF32.buffer,ptr,numValues).slice();}finally{this.draco._free(ptr);}return{value:value,size:numComponents};}},{key:"_deduceAttributeName",value:function _deduceAttributeName(attribute,options){var uniqueId=attribute.unique_id;for(var _i521=0,_Object$entries4=Object.entries(options.extraAttributes||{});_i521<_Object$entries4.length;_i521++){var _Object$entries4$_i=_slicedToArray(_Object$entries4[_i521],2),attributeName=_Object$entries4$_i[0],attributeUniqueId=_Object$entries4$_i[1];if(attributeUniqueId===uniqueId){return attributeName;}}var thisAttributeType=attribute.attribute_type;for(var dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP){var attributeType=this.draco[dracoAttributeConstant];if(attributeType===thisAttributeType){return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant];}}var entryName=options.attributeNameEntry||'name';if(attribute.metadata[entryName]){return attribute.metadata[entryName].string;}return"CUSTOM_ATTRIBUTE_".concat(uniqueId);}},{key:"_getTopLevelMetadata",value:function _getTopLevelMetadata(dracoGeometry){var dracoMetadata=this.decoder.GetMetadata(dracoGeometry);return this._getDracoMetadata(dracoMetadata);}},{key:"_getAttributeMetadata",value:function _getAttributeMetadata(dracoGeometry,attributeId){var dracoMetadata=this.decoder.GetAttributeMetadata(dracoGeometry,attributeId);return this._getDracoMetadata(dracoMetadata);}},{key:"_getDracoMetadata",value:function _getDracoMetadata(dracoMetadata){if(!dracoMetadata||!dracoMetadata.ptr){return{};}var result={};var numEntries=this.metadataQuerier.NumEntries(dracoMetadata);for(var entryIndex=0;entryIndex<numEntries;entryIndex++){var entryName=this.metadataQuerier.GetEntryName(dracoMetadata,entryIndex);result[entryName]=this._getDracoMetadataField(dracoMetadata,entryName);}return result;}},{key:"_getDracoMetadataField",value:function _getDracoMetadataField(dracoMetadata,entryName){var dracoArray=new this.draco.DracoInt32Array();try{this.metadataQuerier.GetIntEntryArray(dracoMetadata,entryName,dracoArray);var intArray=getInt32Array(dracoArray);return{"int":this.metadataQuerier.GetIntEntry(dracoMetadata,entryName),string:this.metadataQuerier.GetStringEntry(dracoMetadata,entryName),"double":this.metadataQuerier.GetDoubleEntry(dracoMetadata,entryName),intArray:intArray};}finally{this.draco.destroy(dracoArray);}}},{key:"_disableAttributeTransforms",value:function _disableAttributeTransforms(options){var _options$quantizedAtt=options.quantizedAttributes,quantizedAttributes=_options$quantizedAtt===void 0?[]:_options$quantizedAtt,_options$octahedronAt=options.octahedronAttributes,octahedronAttributes=_options$octahedronAt===void 0?[]:_options$octahedronAt;var skipAttributes=[].concat(_toConsumableArray(quantizedAttributes),_toConsumableArray(octahedronAttributes));var _iterator25=_createForOfIteratorHelper(skipAttributes),_step25;try{for(_iterator25.s();!(_step25=_iterator25.n()).done;){var dracoAttributeName=_step25.value;this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);}}catch(err){_iterator25.e(err);}finally{_iterator25.f();}}},{key:"_getQuantizationTransform",value:function _getQuantizationTransform(dracoAttribute,options){var _this128=this;var _options$quantizedAtt2=options.quantizedAttributes,quantizedAttributes=_options$quantizedAtt2===void 0?[]:_options$quantizedAtt2;var attribute_type=dracoAttribute.attribute_type();var skip=quantizedAttributes.map(function(type){return _this128.decoder[type];}).includes(attribute_type);if(skip){var _transform2=new this.draco.AttributeQuantizationTransform();try{if(_transform2.InitFromAttribute(dracoAttribute)){return{quantization_bits:_transform2.quantization_bits(),range:_transform2.range(),min_values:new Float32Array([1,2,3]).map(function(i){return _transform2.min_value(i);})};}}finally{this.draco.destroy(_transform2);}}return null;}},{key:"_getOctahedronTransform",value:function _getOctahedronTransform(dracoAttribute,options){var _this129=this;var _options$octahedronAt2=options.octahedronAttributes,octahedronAttributes=_options$octahedronAt2===void 0?[]:_options$octahedronAt2;var attribute_type=dracoAttribute.attribute_type();var octahedron=octahedronAttributes.map(function(type){return _this129.decoder[type];}).includes(attribute_type);if(octahedron){var _transform3=new this.draco.AttributeQuantizationTransform();try{if(_transform3.InitFromAttribute(dracoAttribute)){return{quantization_bits:_transform3.quantization_bits()};}}finally{this.draco.destroy(_transform3);}}return null;}}]);return DracoParser;}();function getDracoDataType(draco,attributeType){switch(attributeType){case Float32Array:return draco.DT_FLOAT32;case Int8Array:return draco.DT_INT8;case Int16Array:return draco.DT_INT16;case Int32Array:return draco.DT_INT32;case Uint8Array:return draco.DT_UINT8;case Uint16Array:return draco.DT_UINT16;case Uint32Array:return draco.DT_UINT32;default:return draco.DT_INVALID;}}function getInt32Array(dracoArray){var numValues=dracoArray.size();var intArray=new Int32Array(numValues);for(var _i522=0;_i522<numValues;_i522++){intArray[_i522]=dracoArray.GetValue(_i522);}return intArray;}function getUint32Array(dracoArray){var numValues=dracoArray.size();var intArray=new Int32Array(numValues);for(var _i523=0;_i523<numValues;_i523++){intArray[_i523]=dracoArray.GetValue(_i523);}return intArray;}var DRACO_VERSION='1.4.1';var DRACO_JS_DECODER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_decoder.js");var DRACO_WASM_WRAPPER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_wasm_wrapper.js");var DRACO_WASM_DECODER_URL="https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_VERSION,"/draco_decoder.wasm");var loadDecoderPromise;function loadDracoDecoderModule(_x68){return _loadDracoDecoderModule.apply(this,arguments);}function _loadDracoDecoderModule(){_loadDracoDecoderModule=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(options){var modules;return _regeneratorRuntime().wrap(function _callee38$(_context42){while(1){switch(_context42.prev=_context42.next){case 0:modules=options.modules||{};if(modules.draco3d){loadDecoderPromise=loadDecoderPromise||modules.draco3d.createDecoderModule({}).then(function(draco){return{draco:draco};});}else{loadDecoderPromise=loadDecoderPromise||loadDracoDecoder(options);}_context42.next=4;return loadDecoderPromise;case 4:return _context42.abrupt("return",_context42.sent);case 5:case"end":return _context42.stop();}}},_callee38);}));return _loadDracoDecoderModule.apply(this,arguments);}function loadDracoDecoder(_x69){return _loadDracoDecoder.apply(this,arguments);}function _loadDracoDecoder(){_loadDracoDecoder=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(options){var DracoDecoderModule,wasmBinary,_yield$Promise$all5,_yield$Promise$all6;return _regeneratorRuntime().wrap(function _callee39$(_context43){while(1){switch(_context43.prev=_context43.next){case 0:_context43.t0=options.draco&&options.draco.decoderType;_context43.next=_context43.t0==='js'?3:_context43.t0==='wasm'?7:7;break;case 3:_context43.next=5;return loadLibrary(DRACO_JS_DECODER_URL,'draco',options);case 5:DracoDecoderModule=_context43.sent;return _context43.abrupt("break",21);case 7:_context43.t1=Promise;_context43.next=10;return loadLibrary(DRACO_WASM_WRAPPER_URL,'draco',options);case 10:_context43.t2=_context43.sent;_context43.next=13;return loadLibrary(DRACO_WASM_DECODER_URL,'draco',options);case 13:_context43.t3=_context43.sent;_context43.t4=[_context43.t2,_context43.t3];_context43.next=17;return _context43.t1.all.call(_context43.t1,_context43.t4);case 17:_yield$Promise$all5=_context43.sent;_yield$Promise$all6=_slicedToArray(_yield$Promise$all5,2);DracoDecoderModule=_yield$Promise$all6[0];wasmBinary=_yield$Promise$all6[1];case 21:DracoDecoderModule=DracoDecoderModule||globalThis.DracoDecoderModule;_context43.next=24;return initializeDracoDecoder(DracoDecoderModule,wasmBinary);case 24:return _context43.abrupt("return",_context43.sent);case 25:case"end":return _context43.stop();}}},_callee39);}));return _loadDracoDecoder.apply(this,arguments);}function initializeDracoDecoder(DracoDecoderModule,wasmBinary){var options={};if(wasmBinary){options.wasmBinary=wasmBinary;}return new Promise(function(resolve){DracoDecoderModule(_objectSpread(_objectSpread({},options),{},{onModuleLoaded:function onModuleLoaded(draco){return resolve({draco:draco});}}));});}({id:isBrowser$3?'draco-writer':'draco-writer-nodejs',name:'Draco compressed geometry writer',module:'draco',version:VERSION$1,worker:true,options:{draco:{},source:null}});var DracoLoader=_objectSpread(_objectSpread({},DracoLoader$1),{},{parse:parse$2});function parse$2(_x70,_x71){return _parse$2.apply(this,arguments);}function _parse$2(){_parse$2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(arrayBuffer,options){var _yield$loadDracoDecod,draco,dracoParser;return _regeneratorRuntime().wrap(function _callee40$(_context44){while(1){switch(_context44.prev=_context44.next){case 0:_context44.next=2;return loadDracoDecoderModule(options);case 2:_yield$loadDracoDecod=_context44.sent;draco=_yield$loadDracoDecod.draco;dracoParser=new DracoParser(draco);_context44.prev=5;return _context44.abrupt("return",dracoParser.parseSync(arrayBuffer,options===null||options===void 0?void 0:options.draco));case 7:_context44.prev=7;dracoParser.destroy();return _context44.finish(7);case 10:case"end":return _context44.stop();}}},_callee40,null,[[5,,7,10]]);}));return _parse$2.apply(this,arguments);}function getGLTFAccessors(attributes){var accessors={};for(var _name7 in attributes){var attribute=attributes[_name7];if(_name7!=='indices'){var glTFAccessor=getGLTFAccessor(attribute);accessors[_name7]=glTFAccessor;}}return accessors;}function getGLTFAccessor(attribute){var _getAccessorData=getAccessorData(attribute),buffer=_getAccessorData.buffer,size=_getAccessorData.size,count=_getAccessorData.count;var glTFAccessor={value:buffer,size:size,byteOffset:0,count:count,type:getAccessorTypeFromSize(size),componentType:getComponentTypeFromArray(buffer)};return glTFAccessor;}function getAccessorData(attribute){var buffer=attribute;var size=1;var count=0;if(attribute&&attribute.value){buffer=attribute.value;size=attribute.size||1;}if(buffer){if(!ArrayBuffer.isView(buffer)){buffer=toTypedArray(buffer,Float32Array);}count=buffer.length/size;}return{buffer:buffer,size:size,count:count};}function toTypedArray(array,ArrayType){var convertTypedArrays=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(!array){return null;}if(Array.isArray(array)){return new ArrayType(array);}if(convertTypedArrays&&!(array instanceof ArrayType)){return new ArrayType(array);}return array;}var KHR_DRACO_MESH_COMPRESSION='KHR_draco_mesh_compression';var name$3=KHR_DRACO_MESH_COMPRESSION;function preprocess$1(gltfData,options,context){var scenegraph=new GLTFScenegraph(gltfData);var _iterator26=_createForOfIteratorHelper(makeMeshPrimitiveIterator(scenegraph)),_step26;try{for(_iterator26.s();!(_step26=_iterator26.n()).done;){var _primitive=_step26.value;if(scenegraph.getObjectExtension(_primitive,KHR_DRACO_MESH_COMPRESSION));}}catch(err){_iterator26.e(err);}finally{_iterator26.f();}}function decode$3(_x72,_x73,_x74){return _decode$2.apply(this,arguments);}function _decode$2(){_decode$2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(gltfData,options,context){var _options$gltf,scenegraph,promises,_iterator50,_step50,_primitive5;return _regeneratorRuntime().wrap(function _callee41$(_context45){while(1){switch(_context45.prev=_context45.next){case 0:if(options!==null&&options!==void 0&&(_options$gltf=options.gltf)!==null&&_options$gltf!==void 0&&_options$gltf.decompressMeshes){_context45.next=2;break;}return _context45.abrupt("return");case 2:scenegraph=new GLTFScenegraph(gltfData);promises=[];_iterator50=_createForOfIteratorHelper(makeMeshPrimitiveIterator(scenegraph));try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){_primitive5=_step50.value;if(scenegraph.getObjectExtension(_primitive5,KHR_DRACO_MESH_COMPRESSION)){promises.push(decompressPrimitive(scenegraph,_primitive5,options,context));}}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}_context45.next=8;return Promise.all(promises);case 8:scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION);case 9:case"end":return _context45.stop();}}},_callee41);}));return _decode$2.apply(this,arguments);}function encode$3(gltfData){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var scenegraph=new GLTFScenegraph(gltfData);var _iterator27=_createForOfIteratorHelper(scenegraph.json.meshes||[]),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var _mesh3=_step27.value;compressMesh(_mesh3);scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION);}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}}function decompressPrimitive(_x75,_x76,_x77,_x78){return _decompressPrimitive.apply(this,arguments);}function _decompressPrimitive(){_decompressPrimitive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(scenegraph,primitive,options,context){var dracoExtension,buffer,bufferCopy,parse,dracoOptions,decodedData,decodedAttributes,_i620,_Object$entries6,_Object$entries6$_i,attributeName,decodedAttribute,accessorIndex,accessor;return _regeneratorRuntime().wrap(function _callee42$(_context46){while(1){switch(_context46.prev=_context46.next){case 0:dracoExtension=scenegraph.getObjectExtension(primitive,KHR_DRACO_MESH_COMPRESSION);if(dracoExtension){_context46.next=3;break;}return _context46.abrupt("return");case 3:buffer=scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);bufferCopy=sliceArrayBuffer(buffer.buffer,buffer.byteOffset);parse=context.parse;dracoOptions=_objectSpread({},options);delete dracoOptions['3d-tiles'];_context46.next=10;return parse(bufferCopy,DracoLoader,dracoOptions,context);case 10:decodedData=_context46.sent;decodedAttributes=getGLTFAccessors(decodedData.attributes);for(_i620=0,_Object$entries6=Object.entries(decodedAttributes);_i620<_Object$entries6.length;_i620++){_Object$entries6$_i=_slicedToArray(_Object$entries6[_i620],2),attributeName=_Object$entries6$_i[0],decodedAttribute=_Object$entries6$_i[1];if(attributeName in primitive.attributes){accessorIndex=primitive.attributes[attributeName];accessor=scenegraph.getAccessor(accessorIndex);if(accessor!==null&&accessor!==void 0&&accessor.min&&accessor!==null&&accessor!==void 0&&accessor.max){decodedAttribute.min=accessor.min;decodedAttribute.max=accessor.max;}}}primitive.attributes=decodedAttributes;if(decodedData.indices){primitive.indices=getGLTFAccessor(decodedData.indices);}checkPrimitive(primitive);case 16:case"end":return _context46.stop();}}},_callee42);}));return _decompressPrimitive.apply(this,arguments);}function compressMesh(attributes,indices){var mode=arguments.length>2&&arguments[2]!==undefined?arguments[2]:4;var options=arguments.length>3?arguments[3]:undefined;var context=arguments.length>4?arguments[4]:undefined;var _context$parseSync;if(!options.DracoWriter){throw new Error('options.gltf.DracoWriter not provided');}var compressedData=options.DracoWriter.encodeSync({attributes:attributes});var decodedData=context===null||context===void 0?void 0:(_context$parseSync=context.parseSync)===null||_context$parseSync===void 0?void 0:_context$parseSync.call(context,{attributes:attributes});var fauxAccessors=options._addFauxAttributes(decodedData.attributes);var bufferViewIndex=options.addBufferView(compressedData);var glTFMesh={primitives:[{attributes:fauxAccessors,mode:mode,extensions:_defineProperty2({},KHR_DRACO_MESH_COMPRESSION,{bufferView:bufferViewIndex,attributes:fauxAccessors})}]};return glTFMesh;}function checkPrimitive(primitive){if(!primitive.attributes&&Object.keys(primitive.attributes).length>0){throw new Error('glTF: Empty primitive detected: Draco decompression failure?');}}function makeMeshPrimitiveIterator(scenegraph){var _iterator28,_step28,_mesh4,_iterator29,_step29,_primitive2;return _regeneratorRuntime().wrap(function makeMeshPrimitiveIterator$(_context10){while(1){switch(_context10.prev=_context10.next){case 0:_iterator28=_createForOfIteratorHelper(scenegraph.json.meshes||[]);_context10.prev=1;_iterator28.s();case 3:if((_step28=_iterator28.n()).done){_context10.next=24;break;}_mesh4=_step28.value;_iterator29=_createForOfIteratorHelper(_mesh4.primitives);_context10.prev=6;_iterator29.s();case 8:if((_step29=_iterator29.n()).done){_context10.next=14;break;}_primitive2=_step29.value;_context10.next=12;return _primitive2;case 12:_context10.next=8;break;case 14:_context10.next=19;break;case 16:_context10.prev=16;_context10.t0=_context10["catch"](6);_iterator29.e(_context10.t0);case 19:_context10.prev=19;_iterator29.f();return _context10.finish(19);case 22:_context10.next=3;break;case 24:_context10.next=29;break;case 26:_context10.prev=26;_context10.t1=_context10["catch"](1);_iterator28.e(_context10.t1);case 29:_context10.prev=29;_iterator28.f();return _context10.finish(29);case 32:case"end":return _context10.stop();}}},_marked3,null,[[1,26,29,32],[6,16,19,22]]);}var KHR_draco_mesh_compression=/*#__PURE__*/Object.freeze({__proto__:null,name:name$3,preprocess:preprocess$1,decode:decode$3,encode:encode$3});var KHR_LIGHTS_PUNCTUAL='KHR_lights_punctual';var name$2=KHR_LIGHTS_PUNCTUAL;function decode$2(_x79){return _decode$3.apply(this,arguments);}function _decode$3(){_decode$3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(gltfData){var gltfScenegraph,json,extension,_iterator51,_step51,_node10,nodeExtension;return _regeneratorRuntime().wrap(function _callee43$(_context47){while(1){switch(_context47.prev=_context47.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;extension=gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);if(extension){gltfScenegraph.json.lights=extension.lights;gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL);}_iterator51=_createForOfIteratorHelper(json.nodes||[]);try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){_node10=_step51.value;nodeExtension=gltfScenegraph.getObjectExtension(_node10,KHR_LIGHTS_PUNCTUAL);if(nodeExtension){_node10.light=nodeExtension.light;}gltfScenegraph.removeObjectExtension(_node10,KHR_LIGHTS_PUNCTUAL);}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}case 6:case"end":return _context47.stop();}}},_callee43);}));return _decode$3.apply(this,arguments);}function encode$2(_x80){return _encode$.apply(this,arguments);}function _encode$(){_encode$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(gltfData){var gltfScenegraph,json,extension,_iterator52,_step52,light,_node11;return _regeneratorRuntime().wrap(function _callee44$(_context48){while(1){switch(_context48.prev=_context48.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;if(json.lights){extension=gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);assert$1(!extension.lights);extension.lights=json.lights;delete json.lights;}if(gltfScenegraph.json.lights){_iterator52=_createForOfIteratorHelper(gltfScenegraph.json.lights);try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){light=_step52.value;_node11=light.node;gltfScenegraph.addObjectExtension(_node11,KHR_LIGHTS_PUNCTUAL,light);}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}delete gltfScenegraph.json.lights;}case 4:case"end":return _context48.stop();}}},_callee44);}));return _encode$.apply(this,arguments);}var KHR_lights_punctual=/*#__PURE__*/Object.freeze({__proto__:null,name:name$2,decode:decode$2,encode:encode$2});var KHR_MATERIALS_UNLIT='KHR_materials_unlit';var name$1=KHR_MATERIALS_UNLIT;function decode$1(_x81){return _decode$4.apply(this,arguments);}function _decode$4(){_decode$4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(gltfData){var gltfScenegraph,json,_iterator53,_step53,material,extension;return _regeneratorRuntime().wrap(function _callee45$(_context49){while(1){switch(_context49.prev=_context49.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);_iterator53=_createForOfIteratorHelper(json.materials||[]);try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){material=_step53.value;extension=material.extensions&&material.extensions.KHR_materials_unlit;if(extension){material.unlit=true;}gltfScenegraph.removeObjectExtension(material,KHR_MATERIALS_UNLIT);}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}case 5:case"end":return _context49.stop();}}},_callee45);}));return _decode$4.apply(this,arguments);}function encode$1(gltfData){var gltfScenegraph=new GLTFScenegraph(gltfData);var json=gltfScenegraph.json;if(gltfScenegraph.materials){var _iterator30=_createForOfIteratorHelper(json.materials||[]),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var material=_step30.value;if(material.unlit){delete material.unlit;gltfScenegraph.addObjectExtension(material,KHR_MATERIALS_UNLIT,{});gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);}}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}}}var KHR_materials_unlit=/*#__PURE__*/Object.freeze({__proto__:null,name:name$1,decode:decode$1,encode:encode$1});var KHR_TECHNIQUES_WEBGL='KHR_techniques_webgl';var name=KHR_TECHNIQUES_WEBGL;function decode(_x82){return _decode.apply(this,arguments);}function _decode(){_decode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(gltfData){var gltfScenegraph,json,extension,techniques,_iterator54,_step54,material,materialExtension;return _regeneratorRuntime().wrap(function _callee46$(_context50){while(1){switch(_context50.prev=_context50.next){case 0:gltfScenegraph=new GLTFScenegraph(gltfData);json=gltfScenegraph.json;extension=gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);if(extension){techniques=resolveTechniques(extension,gltfScenegraph);_iterator54=_createForOfIteratorHelper(json.materials||[]);try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){material=_step54.value;materialExtension=gltfScenegraph.getObjectExtension(material,KHR_TECHNIQUES_WEBGL);if(materialExtension){material.technique=Object.assign({},materialExtension,techniques[materialExtension.technique]);material.technique.values=resolveValues(material.technique,gltfScenegraph);}gltfScenegraph.removeObjectExtension(material,KHR_TECHNIQUES_WEBGL);}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);}case 4:case"end":return _context50.stop();}}},_callee46);}));return _decode.apply(this,arguments);}function encode(_x83,_x84){return _encode.apply(this,arguments);}function _encode(){_encode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(gltfData,options){return _regeneratorRuntime().wrap(function _callee47$(_context51){while(1){switch(_context51.prev=_context51.next){case 0:case"end":return _context51.stop();}}},_callee47);}));return _encode.apply(this,arguments);}function resolveTechniques(techniquesExtension,gltfScenegraph){var _techniquesExtension$=techniquesExtension.programs,programs=_techniquesExtension$===void 0?[]:_techniquesExtension$,_techniquesExtension$2=techniquesExtension.shaders,shaders=_techniquesExtension$2===void 0?[]:_techniquesExtension$2,_techniquesExtension$3=techniquesExtension.techniques,techniques=_techniquesExtension$3===void 0?[]:_techniquesExtension$3;var textDecoder=new TextDecoder();shaders.forEach(function(shader){if(Number.isFinite(shader.bufferView)){shader.code=textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));}else{throw new Error('KHR_techniques_webgl: no shader code');}});programs.forEach(function(program){program.fragmentShader=shaders[program.fragmentShader];program.vertexShader=shaders[program.vertexShader];});techniques.forEach(function(technique){technique.program=programs[technique.program];});return techniques;}function resolveValues(technique,gltfScenegraph){var values=Object.assign({},technique.values);Object.keys(technique.uniforms||{}).forEach(function(uniform){if(technique.uniforms[uniform].value&&!(uniform in values)){values[uniform]=technique.uniforms[uniform].value;}});Object.keys(values).forEach(function(uniform){if(_typeof(values[uniform])==='object'&&values[uniform].index!==undefined){values[uniform].texture=gltfScenegraph.getTexture(values[uniform].index);}});return values;}var KHR_techniques_webgl=/*#__PURE__*/Object.freeze({__proto__:null,name:name,decode:decode,encode:encode});var EXTENSIONS=[EXT_meshopt_compression,EXT_texture_webp,KHR_texture_basisu,KHR_draco_mesh_compression,KHR_lights_punctual,KHR_materials_unlit,KHR_techniques_webgl];function preprocessExtensions(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var context=arguments.length>2?arguments[2]:undefined;var extensions=EXTENSIONS.filter(function(extension){return useExtension(extension.name,options);});var _iterator31=_createForOfIteratorHelper(extensions),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var extension=_step31.value;var _extension$preprocess;(_extension$preprocess=extension.preprocess)===null||_extension$preprocess===void 0?void 0:_extension$preprocess.call(extension,gltf,options,context);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}function decodeExtensions(_x85){return _decodeExtensions.apply(this,arguments);}function _decodeExtensions(){_decodeExtensions=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(gltf){var options,context,extensions,_iterator55,_step55,extension,_extension$decode,_args46=arguments;return _regeneratorRuntime().wrap(function _callee48$(_context52){while(1){switch(_context52.prev=_context52.next){case 0:options=_args46.length>1&&_args46[1]!==undefined?_args46[1]:{};context=_args46.length>2?_args46[2]:undefined;extensions=EXTENSIONS.filter(function(extension){return useExtension(extension.name,options);});_iterator55=_createForOfIteratorHelper(extensions);_context52.prev=4;_iterator55.s();case 6:if((_step55=_iterator55.n()).done){_context52.next=12;break;}extension=_step55.value;_context52.next=10;return(_extension$decode=extension.decode)===null||_extension$decode===void 0?void 0:_extension$decode.call(extension,gltf,options,context);case 10:_context52.next=6;break;case 12:_context52.next=17;break;case 14:_context52.prev=14;_context52.t0=_context52["catch"](4);_iterator55.e(_context52.t0);case 17:_context52.prev=17;_iterator55.f();return _context52.finish(17);case 20:case"end":return _context52.stop();}}},_callee48,null,[[4,14,17,20]]);}));return _decodeExtensions.apply(this,arguments);}function useExtension(extensionName,options){var _options$gltf;var excludes=(options===null||options===void 0?void 0:(_options$gltf=options.gltf)===null||_options$gltf===void 0?void 0:_options$gltf.excludeExtensions)||{};var exclude=extensionName in excludes&&!excludes[extensionName];return!exclude;}var KHR_BINARY_GLTF='KHR_binary_glTF';function preprocess(gltfData){var gltfScenegraph=new GLTFScenegraph(gltfData);var json=gltfScenegraph.json;var _iterator32=_createForOfIteratorHelper(json.images||[]),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _image7=_step32.value;var extension=gltfScenegraph.getObjectExtension(_image7,KHR_BINARY_GLTF);if(extension){Object.assign(_image7,extension);}gltfScenegraph.removeObjectExtension(_image7,KHR_BINARY_GLTF);}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}if(json.buffers&&json.buffers[0]){delete json.buffers[0].uri;}gltfScenegraph.removeExtension(KHR_BINARY_GLTF);}var GLTF_ARRAYS={accessors:'accessor',animations:'animation',buffers:'buffer',bufferViews:'bufferView',images:'image',materials:'material',meshes:'mesh',nodes:'node',samplers:'sampler',scenes:'scene',skins:'skin',textures:'texture'};var GLTF_KEYS={accessor:'accessors',animations:'animation',buffer:'buffers',bufferView:'bufferViews',image:'images',material:'materials',mesh:'meshes',node:'nodes',sampler:'samplers',scene:'scenes',skin:'skins',texture:'textures'};var GLTFV1Normalizer=/*#__PURE__*/function(){function GLTFV1Normalizer(){_classCallCheck(this,GLTFV1Normalizer);_defineProperty(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}});_defineProperty(this,"json",void 0);}_createClass(GLTFV1Normalizer,[{key:"normalize",value:function normalize(gltf,options){this.json=gltf.json;var json=gltf.json;switch(json.asset&&json.asset.version){case'2.0':return;case undefined:case'1.0':break;default:console.warn("glTF: Unknown version ".concat(json.asset.version));return;}if(!options.normalize){throw new Error('glTF v1 is not supported.');}console.warn('Converting glTF v1 to glTF v2 format. This is experimental and may fail.');this._addAsset(json);this._convertTopLevelObjectsToArrays(json);preprocess(gltf);this._convertObjectIdsToArrayIndices(json);this._updateObjects(json);this._updateMaterial(json);}},{key:"_addAsset",value:function _addAsset(json){json.asset=json.asset||{};json.asset.version='2.0';json.asset.generator=json.asset.generator||'Normalized to glTF 2.0 by loaders.gl';}},{key:"_convertTopLevelObjectsToArrays",value:function _convertTopLevelObjectsToArrays(json){for(var arrayName in GLTF_ARRAYS){this._convertTopLevelObjectToArray(json,arrayName);}}},{key:"_convertTopLevelObjectToArray",value:function _convertTopLevelObjectToArray(json,mapName){var objectMap=json[mapName];if(!objectMap||Array.isArray(objectMap)){return;}json[mapName]=[];for(var id in objectMap){var object=objectMap[id];object.id=object.id||id;var index=json[mapName].length;json[mapName].push(object);this.idToIndexMap[mapName][id]=index;}}},{key:"_convertObjectIdsToArrayIndices",value:function _convertObjectIdsToArrayIndices(json){for(var arrayName in GLTF_ARRAYS){this._convertIdsToIndices(json,arrayName);}if('scene'in json){json.scene=this._convertIdToIndex(json.scene,'scene');}var _iterator33=_createForOfIteratorHelper(json.textures),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var texture=_step33.value;this._convertTextureIds(texture);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}var _iterator34=_createForOfIteratorHelper(json.meshes),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _mesh5=_step34.value;this._convertMeshIds(_mesh5);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}var _iterator35=_createForOfIteratorHelper(json.nodes),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var _node4=_step35.value;this._convertNodeIds(_node4);}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}var _iterator36=_createForOfIteratorHelper(json.scenes),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _node5=_step36.value;this._convertSceneIds(_node5);}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}}},{key:"_convertTextureIds",value:function _convertTextureIds(texture){if(texture.source){texture.source=this._convertIdToIndex(texture.source,'image');}}},{key:"_convertMeshIds",value:function _convertMeshIds(mesh){var _iterator37=_createForOfIteratorHelper(mesh.primitives),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var _primitive3=_step37.value;var attributes=_primitive3.attributes,indices=_primitive3.indices,material=_primitive3.material;for(var attributeName in attributes){attributes[attributeName]=this._convertIdToIndex(attributes[attributeName],'accessor');}if(indices){_primitive3.indices=this._convertIdToIndex(indices,'accessor');}if(material){_primitive3.material=this._convertIdToIndex(material,'material');}}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}}},{key:"_convertNodeIds",value:function _convertNodeIds(node){var _this130=this;if(node.children){node.children=node.children.map(function(child){return _this130._convertIdToIndex(child,'node');});}if(node.meshes){node.meshes=node.meshes.map(function(mesh){return _this130._convertIdToIndex(mesh,'mesh');});}}},{key:"_convertSceneIds",value:function _convertSceneIds(scene){var _this131=this;if(scene.nodes){scene.nodes=scene.nodes.map(function(node){return _this131._convertIdToIndex(node,'node');});}}},{key:"_convertIdsToIndices",value:function _convertIdsToIndices(json,topLevelArrayName){if(!json[topLevelArrayName]){console.warn("gltf v1: json doesn't contain attribute ".concat(topLevelArrayName));json[topLevelArrayName]=[];}var _iterator38=_createForOfIteratorHelper(json[topLevelArrayName]),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var object=_step38.value;for(var key in object){var id=object[key];var index=this._convertIdToIndex(id,key);object[key]=index;}}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}}},{key:"_convertIdToIndex",value:function _convertIdToIndex(id,key){var arrayName=GLTF_KEYS[key];if(arrayName in this.idToIndexMap){var index=this.idToIndexMap[arrayName][id];if(!Number.isFinite(index)){throw new Error("gltf v1: failed to resolve ".concat(key," with id ").concat(id));}return index;}return id;}},{key:"_updateObjects",value:function _updateObjects(json){var _iterator39=_createForOfIteratorHelper(this.json.buffers),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var buffer=_step39.value;delete buffer.type;}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}}},{key:"_updateMaterial",value:function _updateMaterial(json){var _iterator40=_createForOfIteratorHelper(json.materials),_step40;try{var _loop6=function _loop6(){var material=_step40.value;material.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};var textureId=((_material$values=material.values)===null||_material$values===void 0?void 0:_material$values.tex)||((_material$values2=material.values)===null||_material$values2===void 0?void 0:_material$values2.texture2d_0);var textureIndex=json.textures.findIndex(function(texture){return texture.id===textureId;});if(textureIndex!==-1){material.pbrMetallicRoughness.baseColorTexture={index:textureIndex};}};for(_iterator40.s();!(_step40=_iterator40.n()).done;){var _material$values,_material$values2;_loop6();}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}}]);return GLTFV1Normalizer;}();function normalizeGLTFV1(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return new GLTFV1Normalizer().normalize(gltf,options);}var COMPONENTS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var BYTES={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var GL_SAMPLER={TEXTURE_MAG_FILTER:0x2800,TEXTURE_MIN_FILTER:0x2801,TEXTURE_WRAP_S:0x2802,TEXTURE_WRAP_T:0x2803,REPEAT:0x2901,LINEAR:0x2601,NEAREST_MIPMAP_LINEAR:0x2702};var SAMPLER_PARAMETER_GLTF_TO_GL={magFilter:GL_SAMPLER.TEXTURE_MAG_FILTER,minFilter:GL_SAMPLER.TEXTURE_MIN_FILTER,wrapS:GL_SAMPLER.TEXTURE_WRAP_S,wrapT:GL_SAMPLER.TEXTURE_WRAP_T};var DEFAULT_SAMPLER=(_DEFAULT_SAMPLER={},_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_MAG_FILTER,GL_SAMPLER.LINEAR),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_MIN_FILTER,GL_SAMPLER.NEAREST_MIPMAP_LINEAR),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_WRAP_S,GL_SAMPLER.REPEAT),_defineProperty2(_DEFAULT_SAMPLER,GL_SAMPLER.TEXTURE_WRAP_T,GL_SAMPLER.REPEAT),_DEFAULT_SAMPLER);function getBytesFromComponentType(componentType){return BYTES[componentType];}function getSizeFromAccessorType(type){return COMPONENTS[type];}var GLTFPostProcessor=/*#__PURE__*/function(){function GLTFPostProcessor(){_classCallCheck(this,GLTFPostProcessor);_defineProperty(this,"baseUri",'');_defineProperty(this,"json",{});_defineProperty(this,"buffers",[]);_defineProperty(this,"images",[]);}_createClass(GLTFPostProcessor,[{key:"postProcess",value:function postProcess(gltf){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var json=gltf.json,_gltf$buffers=gltf.buffers,buffers=_gltf$buffers===void 0?[]:_gltf$buffers,_gltf$images=gltf.images,images=_gltf$images===void 0?[]:_gltf$images,_gltf$baseUri=gltf.baseUri,baseUri=_gltf$baseUri===void 0?'':_gltf$baseUri;assert$1(json);this.baseUri=baseUri;this.json=json;this.buffers=buffers;this.images=images;this._resolveTree(this.json,options);return this.json;}},{key:"_resolveTree",value:function _resolveTree(json){var _this132=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(json.bufferViews){json.bufferViews=json.bufferViews.map(function(bufView,i){return _this132._resolveBufferView(bufView,i);});}if(json.images){json.images=json.images.map(function(image,i){return _this132._resolveImage(image,i);});}if(json.samplers){json.samplers=json.samplers.map(function(sampler,i){return _this132._resolveSampler(sampler,i);});}if(json.textures){json.textures=json.textures.map(function(texture,i){return _this132._resolveTexture(texture,i);});}if(json.accessors){json.accessors=json.accessors.map(function(accessor,i){return _this132._resolveAccessor(accessor,i);});}if(json.materials){json.materials=json.materials.map(function(material,i){return _this132._resolveMaterial(material,i);});}if(json.meshes){json.meshes=json.meshes.map(function(mesh,i){return _this132._resolveMesh(mesh,i);});}if(json.nodes){json.nodes=json.nodes.map(function(node,i){return _this132._resolveNode(node,i);});}if(json.skins){json.skins=json.skins.map(function(skin,i){return _this132._resolveSkin(skin,i);});}if(json.scenes){json.scenes=json.scenes.map(function(scene,i){return _this132._resolveScene(scene,i);});}if(json.scene!==undefined){json.scene=json.scenes[this.json.scene];}}},{key:"getScene",value:function getScene(index){return this._get('scenes',index);}},{key:"getNode",value:function getNode(index){return this._get('nodes',index);}},{key:"getSkin",value:function getSkin(index){return this._get('skins',index);}},{key:"getMesh",value:function getMesh(index){return this._get('meshes',index);}},{key:"getMaterial",value:function getMaterial(index){return this._get('materials',index);}},{key:"getAccessor",value:function getAccessor(index){return this._get('accessors',index);}},{key:"getCamera",value:function getCamera(index){return null;}},{key:"getTexture",value:function getTexture(index){return this._get('textures',index);}},{key:"getSampler",value:function getSampler(index){return this._get('samplers',index);}},{key:"getImage",value:function getImage(index){return this._get('images',index);}},{key:"getBufferView",value:function getBufferView(index){return this._get('bufferViews',index);}},{key:"getBuffer",value:function getBuffer(index){return this._get('buffers',index);}},{key:"_get",value:function _get(array,index){if(_typeof(index)==='object'){return index;}var object=this.json[array]&&this.json[array][index];if(!object){console.warn("glTF file error: Could not find ".concat(array,"[").concat(index,"]"));}return object;}},{key:"_resolveScene",value:function _resolveScene(scene,index){var _this133=this;scene.id=scene.id||"scene-".concat(index);scene.nodes=(scene.nodes||[]).map(function(node){return _this133.getNode(node);});return scene;}},{key:"_resolveNode",value:function _resolveNode(node,index){var _this134=this;node.id=node.id||"node-".concat(index);if(node.children){node.children=node.children.map(function(child){return _this134.getNode(child);});}if(node.mesh!==undefined){node.mesh=this.getMesh(node.mesh);}else if(node.meshes!==undefined&&node.meshes.length){node.mesh=node.meshes.reduce(function(accum,meshIndex){var mesh=_this134.getMesh(meshIndex);accum.id=mesh.id;accum.primitives=accum.primitives.concat(mesh.primitives);return accum;},{primitives:[]});}if(node.camera!==undefined){node.camera=this.getCamera(node.camera);}if(node.skin!==undefined){node.skin=this.getSkin(node.skin);}return node;}},{key:"_resolveSkin",value:function _resolveSkin(skin,index){skin.id=skin.id||"skin-".concat(index);skin.inverseBindMatrices=this.getAccessor(skin.inverseBindMatrices);return skin;}},{key:"_resolveMesh",value:function _resolveMesh(mesh,index){var _this135=this;mesh.id=mesh.id||"mesh-".concat(index);if(mesh.primitives){mesh.primitives=mesh.primitives.map(function(primitive){primitive=_objectSpread({},primitive);var attributes=primitive.attributes;primitive.attributes={};for(var attribute in attributes){primitive.attributes[attribute]=_this135.getAccessor(attributes[attribute]);}if(primitive.indices!==undefined){primitive.indices=_this135.getAccessor(primitive.indices);}if(primitive.material!==undefined){primitive.material=_this135.getMaterial(primitive.material);}return primitive;});}return mesh;}},{key:"_resolveMaterial",value:function _resolveMaterial(material,index){material.id=material.id||"material-".concat(index);if(material.normalTexture){material.normalTexture=_objectSpread({},material.normalTexture);material.normalTexture.texture=this.getTexture(material.normalTexture.index);}if(material.occlusionTexture){material.occlustionTexture=_objectSpread({},material.occlustionTexture);material.occlusionTexture.texture=this.getTexture(material.occlusionTexture.index);}if(material.emissiveTexture){material.emmisiveTexture=_objectSpread({},material.emmisiveTexture);material.emissiveTexture.texture=this.getTexture(material.emissiveTexture.index);}if(!material.emissiveFactor){material.emissiveFactor=material.emmisiveTexture?[1,1,1]:[0,0,0];}if(material.pbrMetallicRoughness){material.pbrMetallicRoughness=_objectSpread({},material.pbrMetallicRoughness);var mr=material.pbrMetallicRoughness;if(mr.baseColorTexture){mr.baseColorTexture=_objectSpread({},mr.baseColorTexture);mr.baseColorTexture.texture=this.getTexture(mr.baseColorTexture.index);}if(mr.metallicRoughnessTexture){mr.metallicRoughnessTexture=_objectSpread({},mr.metallicRoughnessTexture);mr.metallicRoughnessTexture.texture=this.getTexture(mr.metallicRoughnessTexture.index);}}return material;}},{key:"_resolveAccessor",value:function _resolveAccessor(accessor,index){accessor.id=accessor.id||"accessor-".concat(index);if(accessor.bufferView!==undefined){accessor.bufferView=this.getBufferView(accessor.bufferView);}accessor.bytesPerComponent=getBytesFromComponentType(accessor.componentType);accessor.components=getSizeFromAccessorType(accessor.type);accessor.bytesPerElement=accessor.bytesPerComponent*accessor.components;if(accessor.bufferView){var buffer=accessor.bufferView.buffer;var _getAccessorArrayType2=getAccessorArrayTypeAndLength(accessor,accessor.bufferView),ArrayType=_getAccessorArrayType2.ArrayType,byteLength=_getAccessorArrayType2.byteLength;var byteOffset=(accessor.bufferView.byteOffset||0)+(accessor.byteOffset||0)+buffer.byteOffset;var cutBuffer=buffer.arrayBuffer.slice(byteOffset,byteOffset+byteLength);if(accessor.bufferView.byteStride){cutBuffer=this._getValueFromInterleavedBuffer(buffer,byteOffset,accessor.bufferView.byteStride,accessor.bytesPerElement,accessor.count);}accessor.value=new ArrayType(cutBuffer);}return accessor;}},{key:"_getValueFromInterleavedBuffer",value:function _getValueFromInterleavedBuffer(buffer,byteOffset,byteStride,bytesPerElement,count){var result=new Uint8Array(count*bytesPerElement);for(var _i524=0;_i524<count;_i524++){var elementOffset=byteOffset+_i524*byteStride;result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset,elementOffset+bytesPerElement)),_i524*bytesPerElement);}return result.buffer;}},{key:"_resolveTexture",value:function _resolveTexture(texture,index){texture.id=texture.id||"texture-".concat(index);texture.sampler='sampler'in texture?this.getSampler(texture.sampler):DEFAULT_SAMPLER;texture.source=this.getImage(texture.source);return texture;}},{key:"_resolveSampler",value:function _resolveSampler(sampler,index){sampler.id=sampler.id||"sampler-".concat(index);sampler.parameters={};for(var key in sampler){var glEnum=this._enumSamplerParameter(key);if(glEnum!==undefined){sampler.parameters[glEnum]=sampler[key];}}return sampler;}},{key:"_enumSamplerParameter",value:function _enumSamplerParameter(key){return SAMPLER_PARAMETER_GLTF_TO_GL[key];}},{key:"_resolveImage",value:function _resolveImage(image,index){image.id=image.id||"image-".concat(index);if(image.bufferView!==undefined){image.bufferView=this.getBufferView(image.bufferView);}var preloadedImage=this.images[index];if(preloadedImage){image.image=preloadedImage;}return image;}},{key:"_resolveBufferView",value:function _resolveBufferView(bufferView,index){var bufferIndex=bufferView.buffer;var result=_objectSpread(_objectSpread({id:"bufferView-".concat(index)},bufferView),{},{buffer:this.buffers[bufferIndex]});var arrayBuffer=this.buffers[bufferIndex].arrayBuffer;var byteOffset=this.buffers[bufferIndex].byteOffset||0;if('byteOffset'in bufferView){byteOffset+=bufferView.byteOffset;}result.data=new Uint8Array(arrayBuffer,byteOffset,bufferView.byteLength);return result;}},{key:"_resolveCamera",value:function _resolveCamera(camera,index){camera.id=camera.id||"camera-".concat(index);if(camera.perspective);if(camera.orthographic);return camera;}}]);return GLTFPostProcessor;}();function postProcessGLTF(gltf,options){return new GLTFPostProcessor().postProcess(gltf,options);}var MAGIC_glTF=0x676c5446;var GLB_FILE_HEADER_SIZE=12;var GLB_CHUNK_HEADER_SIZE=8;var GLB_CHUNK_TYPE_JSON=0x4e4f534a;var GLB_CHUNK_TYPE_BIN=0x004e4942;var GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED=0;var GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED=1;var GLB_V1_CONTENT_FORMAT_JSON=0x0;var LE=true;function getMagicString(dataView){var byteOffset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return"".concat(String.fromCharCode(dataView.getUint8(byteOffset+0))).concat(String.fromCharCode(dataView.getUint8(byteOffset+1))).concat(String.fromCharCode(dataView.getUint8(byteOffset+2))).concat(String.fromCharCode(dataView.getUint8(byteOffset+3)));}function isGLB(arrayBuffer){var byteOffset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var dataView=new DataView(arrayBuffer);var _options$magic=options.magic,magic=_options$magic===void 0?MAGIC_glTF:_options$magic;var magic1=dataView.getUint32(byteOffset,false);return magic1===magic||magic1===MAGIC_glTF;}function parseGLBSync(glb,arrayBuffer){var byteOffset=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var options=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var dataView=new DataView(arrayBuffer);var type=getMagicString(dataView,byteOffset+0);var version=dataView.getUint32(byteOffset+4,LE);var byteLength=dataView.getUint32(byteOffset+8,LE);Object.assign(glb,{header:{byteOffset:byteOffset,byteLength:byteLength,hasBinChunk:false},type:type,version:version,json:{},binChunks:[]});byteOffset+=GLB_FILE_HEADER_SIZE;switch(glb.version){case 1:return parseGLBV1(glb,dataView,byteOffset);case 2:return parseGLBV2(glb,dataView,byteOffset,options={});default:throw new Error("Invalid GLB version ".concat(glb.version,". Only supports v1 and v2."));}}function parseGLBV1(glb,dataView,byteOffset){assert$5(glb.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE);var contentLength=dataView.getUint32(byteOffset+0,LE);var contentFormat=dataView.getUint32(byteOffset+4,LE);byteOffset+=GLB_CHUNK_HEADER_SIZE;assert$5(contentFormat===GLB_V1_CONTENT_FORMAT_JSON);parseJSONChunk(glb,dataView,byteOffset,contentLength);byteOffset+=contentLength;byteOffset+=parseBINChunk(glb,dataView,byteOffset,glb.header.byteLength);return byteOffset;}function parseGLBV2(glb,dataView,byteOffset,options){assert$5(glb.header.byteLength>GLB_FILE_HEADER_SIZE+GLB_CHUNK_HEADER_SIZE);parseGLBChunksSync(glb,dataView,byteOffset,options);return byteOffset+glb.header.byteLength;}function parseGLBChunksSync(glb,dataView,byteOffset,options){while(byteOffset+8<=glb.header.byteLength){var chunkLength=dataView.getUint32(byteOffset+0,LE);var chunkFormat=dataView.getUint32(byteOffset+4,LE);byteOffset+=GLB_CHUNK_HEADER_SIZE;switch(chunkFormat){case GLB_CHUNK_TYPE_JSON:parseJSONChunk(glb,dataView,byteOffset,chunkLength);break;case GLB_CHUNK_TYPE_BIN:parseBINChunk(glb,dataView,byteOffset,chunkLength);break;case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:if(!options.strict){parseJSONChunk(glb,dataView,byteOffset,chunkLength);}break;case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:if(!options.strict){parseBINChunk(glb,dataView,byteOffset,chunkLength);}break;}byteOffset+=padToNBytes(chunkLength,4);}return byteOffset;}function parseJSONChunk(glb,dataView,byteOffset,chunkLength){var jsonChunk=new Uint8Array(dataView.buffer,byteOffset,chunkLength);var textDecoder=new TextDecoder('utf8');var jsonText=textDecoder.decode(jsonChunk);glb.json=JSON.parse(jsonText);return padToNBytes(chunkLength,4);}function parseBINChunk(glb,dataView,byteOffset,chunkLength){glb.header.hasBinChunk=true;glb.binChunks.push({byteOffset:byteOffset,byteLength:chunkLength,arrayBuffer:dataView.buffer});return padToNBytes(chunkLength,4);}function parseGLTF$1(_x86,_x87){return _parseGLTF$.apply(this,arguments);}function _parseGLTF$(){_parseGLTF$=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(gltf,arrayBufferOrString){var byteOffset,options,context,_options$gltf,_options$gltf2,_options$gltf3,_options$gltf4,promises,_promise,promise,_args47=arguments;return _regeneratorRuntime().wrap(function _callee49$(_context53){while(1){switch(_context53.prev=_context53.next){case 0:byteOffset=_args47.length>2&&_args47[2]!==undefined?_args47[2]:0;options=_args47.length>3?_args47[3]:undefined;context=_args47.length>4?_args47[4]:undefined;parseGLTFContainerSync(gltf,arrayBufferOrString,byteOffset,options);normalizeGLTFV1(gltf,{normalize:options===null||options===void 0?void 0:(_options$gltf=options.gltf)===null||_options$gltf===void 0?void 0:_options$gltf.normalize});preprocessExtensions(gltf,options,context);promises=[];if(!(options!==null&&options!==void 0&&(_options$gltf2=options.gltf)!==null&&_options$gltf2!==void 0&&_options$gltf2.loadBuffers&&gltf.json.buffers)){_context53.next=10;break;}_context53.next=10;return loadBuffers(gltf,options,context);case 10:if(options!==null&&options!==void 0&&(_options$gltf3=options.gltf)!==null&&_options$gltf3!==void 0&&_options$gltf3.loadImages){_promise=loadImages(gltf,options,context);promises.push(_promise);}promise=decodeExtensions(gltf,options,context);promises.push(promise);_context53.next=15;return Promise.all(promises);case 15:return _context53.abrupt("return",options!==null&&options!==void 0&&(_options$gltf4=options.gltf)!==null&&_options$gltf4!==void 0&&_options$gltf4.postProcess?postProcessGLTF(gltf,options):gltf);case 16:case"end":return _context53.stop();}}},_callee49);}));return _parseGLTF$.apply(this,arguments);}function parseGLTFContainerSync(gltf,data,byteOffset,options){if(options.uri){gltf.baseUri=options.uri;}if(data instanceof ArrayBuffer&&!isGLB(data,byteOffset,options)){var textDecoder=new TextDecoder();data=textDecoder.decode(data);}if(typeof data==='string'){gltf.json=parseJSON(data);}else if(data instanceof ArrayBuffer){var glb={};byteOffset=parseGLBSync(glb,data,byteOffset,options.glb);assert$1(glb.type==='glTF',"Invalid GLB magic string ".concat(glb.type));gltf._glb=glb;gltf.json=glb.json;}else{assert$1(false,'GLTF: must be ArrayBuffer or string');}var buffers=gltf.json.buffers||[];gltf.buffers=new Array(buffers.length).fill(null);if(gltf._glb&&gltf._glb.header.hasBinChunk){var binChunks=gltf._glb.binChunks;gltf.buffers[0]={arrayBuffer:binChunks[0].arrayBuffer,byteOffset:binChunks[0].byteOffset,byteLength:binChunks[0].byteLength};}var images=gltf.json.images||[];gltf.images=new Array(images.length).fill({});}function loadBuffers(_x88,_x89,_x90){return _loadBuffers.apply(this,arguments);}function _loadBuffers(){_loadBuffers=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(gltf,options,context){var buffers,_i621,buffer,_context$fetch,_response$arrayBuffer,_fetch,uri,response,arrayBuffer;return _regeneratorRuntime().wrap(function _callee50$(_context54){while(1){switch(_context54.prev=_context54.next){case 0:buffers=gltf.json.buffers||[];_i621=0;case 2:if(!(_i621<buffers.length)){_context54.next=22;break;}buffer=buffers[_i621];if(!buffer.uri){_context54.next=18;break;}_fetch=context.fetch;assert$1(_fetch);uri=resolveUrl(buffer.uri,options);_context54.next=10;return context===null||context===void 0?void 0:(_context$fetch=context.fetch)===null||_context$fetch===void 0?void 0:_context$fetch.call(context,uri);case 10:response=_context54.sent;_context54.next=13;return response===null||response===void 0?void 0:(_response$arrayBuffer=response.arrayBuffer)===null||_response$arrayBuffer===void 0?void 0:_response$arrayBuffer.call(response);case 13:arrayBuffer=_context54.sent;gltf.buffers[_i621]={arrayBuffer:arrayBuffer,byteOffset:0,byteLength:arrayBuffer.byteLength};delete buffer.uri;_context54.next=19;break;case 18:if(gltf.buffers[_i621]===null){gltf.buffers[_i621]={arrayBuffer:new ArrayBuffer(buffer.byteLength),byteOffset:0,byteLength:buffer.byteLength};}case 19:++_i621;_context54.next=2;break;case 22:case"end":return _context54.stop();}}},_callee50);}));return _loadBuffers.apply(this,arguments);}function loadImages(_x91,_x92,_x93){return _loadImages.apply(this,arguments);}function _loadImages(){_loadImages=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(gltf,options,context){var imageIndices,images,promises,_iterator56,_step56,imageIndex;return _regeneratorRuntime().wrap(function _callee51$(_context55){while(1){switch(_context55.prev=_context55.next){case 0:imageIndices=getReferencesImageIndices(gltf);images=gltf.json.images||[];promises=[];_iterator56=_createForOfIteratorHelper(imageIndices);try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){imageIndex=_step56.value;promises.push(loadImage(gltf,images[imageIndex],imageIndex,options,context));}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}_context55.next=7;return Promise.all(promises);case 7:return _context55.abrupt("return",_context55.sent);case 8:case"end":return _context55.stop();}}},_callee51);}));return _loadImages.apply(this,arguments);}function getReferencesImageIndices(gltf){var imageIndices=new Set();var textures=gltf.json.textures||[];var _iterator41=_createForOfIteratorHelper(textures),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var texture=_step41.value;if(texture.source!==undefined){imageIndices.add(texture.source);}}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}return Array.from(imageIndices).sort();}function loadImage(_x94,_x95,_x96,_x97,_x98){return _loadImage.apply(this,arguments);}function _loadImage(){_loadImage=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(gltf,image,index,options,context){var fetch,parse,arrayBuffer,uri,response,array,parsedImage;return _regeneratorRuntime().wrap(function _callee52$(_context56){while(1){switch(_context56.prev=_context56.next){case 0:fetch=context.fetch,parse=context.parse;if(!image.uri){_context56.next=9;break;}uri=resolveUrl(image.uri,options);_context56.next=5;return fetch(uri);case 5:response=_context56.sent;_context56.next=8;return response.arrayBuffer();case 8:arrayBuffer=_context56.sent;case 9:if(Number.isFinite(image.bufferView)){array=getTypedArrayForBufferView(gltf.json,gltf.buffers,image.bufferView);arrayBuffer=sliceArrayBuffer(array.buffer,array.byteOffset,array.byteLength);}assert$1(arrayBuffer,'glTF image has no data');_context56.next=13;return parse(arrayBuffer,[ImageLoader,BasisLoader],{mimeType:image.mimeType,basis:options.basis||{format:selectSupportedBasisFormat()}},context);case 13:parsedImage=_context56.sent;if(parsedImage&&parsedImage[0]){parsedImage={compressed:true,mipmaps:false,width:parsedImage[0].width,height:parsedImage[0].height,data:parsedImage[0]};}gltf.images=gltf.images||[];gltf.images[index]=parsedImage;case 17:case"end":return _context56.stop();}}},_callee52);}));return _loadImage.apply(this,arguments);}var GLTFLoader={name:'glTF',id:'gltf',module:'gltf',version:VERSION$5,extensions:['gltf','glb'],mimeTypes:['model/gltf+json','model/gltf-binary'],text:true,binary:true,tests:['glTF'],parse:parse$1,options:{gltf:{normalize:true,loadBuffers:true,loadImages:true,decompressMeshes:true,postProcess:true},log:console},deprecatedOptions:{fetchImages:'gltf.loadImages',createImages:'gltf.loadImages',decompress:'gltf.decompressMeshes',postProcess:'gltf.postProcess',gltf:{decompress:'gltf.decompressMeshes'}}};function parse$1(_x99){return _parse$3.apply(this,arguments);}/**
|
|
25197
25216
|
* @private
|
|
25198
25217
|
*/function _parse$3(){_parse$3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(arrayBuffer){var options,context,_options2,_options2$byteOffset,byteOffset,gltf,_args51=arguments;return _regeneratorRuntime().wrap(function _callee53$(_context57){while(1){switch(_context57.prev=_context57.next){case 0:options=_args51.length>1&&_args51[1]!==undefined?_args51[1]:{};context=_args51.length>2?_args51[2]:undefined;options=_objectSpread(_objectSpread({},GLTFLoader.options),options);options.gltf=_objectSpread(_objectSpread({},GLTFLoader.options.gltf),options.gltf);_options2=options,_options2$byteOffset=_options2.byteOffset,byteOffset=_options2$byteOffset===void 0?0:_options2$byteOffset;gltf={};_context57.next=8;return parseGLTF$1(gltf,arrayBuffer,byteOffset,options,context);case 8:return _context57.abrupt("return",_context57.sent);case 9:case"end":return _context57.stop();}}},_callee53);}));return _parse$3.apply(this,arguments);}var GLTFSceneModelLoader=/*#__PURE__*/function(){function GLTFSceneModelLoader(cfg){_classCallCheck(this,GLTFSceneModelLoader);}_createClass(GLTFSceneModelLoader,[{key:"load",value:function load(plugin,src,metaModelJSON,options,sceneModel,ok,error){options=options||{};loadGLTF(plugin,src,metaModelJSON,options,sceneModel,function(){core.scheduleTask(function(){sceneModel.scene.fire("modelLoaded",sceneModel.id);// FIXME: Assumes listeners know order of these two events
|
|
25199
25218
|
sceneModel.fire("loaded",true,false);});if(ok){ok();}},function(msg){plugin.error(msg);if(error){error(msg);}sceneModel.fire("error",msg);});}},{key:"parse",value:function parse(plugin,gltf,metaModelJSON,options,sceneModel,ok,error){options=options||{};parseGLTF(plugin,"",gltf,metaModelJSON,options,sceneModel,function(){sceneModel.scene.fire("modelLoaded",sceneModel.id);// FIXME: Assumes listeners know order of these two events
|
|
@@ -25904,7 +25923,7 @@ console.warn('loadFile: HTTP Status 0 received.');if(ok){ok(response);}}else{if(
|
|
|
25904
25923
|
*/_createClass(OBJLoaderPlugin,[{key:"load",value:function load(){var _this140=this;var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(params.id&&this.viewer.scene.components[params.id]){this.error("Component with this ID already exists in viewer: "+params.id+" - will autogenerate this ID");delete params.id;}var modelNode=new Node$2(this.viewer.scene,utils.apply(params,{isModel:true}));var modelId=modelNode.id;// In case ID was auto-generated
|
|
25905
25924
|
var src=params.src;if(!src){this.error("load() param expected: src");return modelNode;}if(params.metaModelSrc){var metaModelSrc=params.metaModelSrc;utils.loadJSON(metaModelSrc,function(modelMetadata){_this140.viewer.metaScene.createMetaModel(modelId,modelMetadata);_this140._sceneGraphLoader.load(modelNode,src,params);},function(errMsg){_this140.error("load(): Failed to load model modelMetadata for model '".concat(modelId," from '").concat(metaModelSrc,"' - ").concat(errMsg));});}else{this._sceneGraphLoader.load(modelNode,src,params);}modelNode.once("destroyed",function(){_this140.viewer.metaScene.destroyMetaModel(modelId);});return modelNode;}/**
|
|
25906
25925
|
* Destroys this OBJLoaderPlugin.
|
|
25907
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(OBJLoaderPlugin.prototype),"destroy",this).call(this);}}]);return OBJLoaderPlugin;}(Plugin)
|
|
25926
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(OBJLoaderPlugin.prototype),"destroy",this).call(this);}}]);return OBJLoaderPlugin;}(Plugin);/**
|
|
25908
25927
|
* Controls a {@link SectionPlane} with mouse and touch input.
|
|
25909
25928
|
*
|
|
25910
25929
|
* @private
|
|
@@ -25920,8 +25939,8 @@ var NO_STATE_INHERIT=false;var arrowLength=1.0;var handleRadius=0.09;var tubeRad
|
|
|
25920
25939
|
position:[0,0,0],scale:[5,5,5],isObject:false});var pos=math.vec3();var setPos=function(){var origin=math.vec3();var rtcPos=math.vec3();return function(p){pos.set(p);worldToRTCPos(p,origin,rtcPos);rootNode.origin=origin;rootNode.position=rtcPos;};}();var arrowGeometry=function arrowGeometry(radiusBottom,height){return new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:0.001,radiusBottom:radiusBottom,radialSegments:32,heightSegments:1,height:height,openEnded:false}));};var tubeGeometry=function tubeGeometry(radius,height,radialSegments){return new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:radius,radiusBottom:radius,radialSegments:radialSegments,heightSegments:1,height:height,openEnded:false}));};var torusGeometry=function torusGeometry(tube,arcFraction,tubeSegments){return new ReadableGeometry(rootNode,buildTorusGeometry({radius:arrowLength-0.2,tube:tube,radialSegments:64,tubeSegments:tubeSegments,arc:Math.PI*2.0*arcFraction}));};var shapes={// Reusable geometries
|
|
25921
25940
|
curve:torusGeometry(tubeRadius,0.25,14),curveHandle:torusGeometry(handleRadius,0.25,14),hoop:torusGeometry(tubeRadius,1,8),arrowHead:arrowGeometry(0.07,0.2),arrowHeadBig:arrowGeometry(0.09,0.25),arrowHeadHandle:tubeGeometry(handleRadius,0.37,8),axis:tubeGeometry(tubeRadius,arrowLength,20),axisHandle:tubeGeometry(handleRadius,arrowLength,20)};var colorMaterial=function colorMaterial(rgb){return new PhongMaterial(rootNode,{diffuse:rgb,emissive:rgb,ambient:[0.0,0.0,0.0],specular:[.6,.6,.3],shininess:80,lineWidth:2});};var highlightMaterial=function highlightMaterial(rgb,fillAlpha){return new EmphasisMaterial(rootNode,{edges:false,fill:true,fillColor:rgb,fillAlpha:fillAlpha});};var pickableMaterial=new PhongMaterial(rootNode,{// Invisible material for pickable handles, which define a pickable 3D area
|
|
25922
25941
|
diffuse:[1,1,0],alpha:0,// Invisible
|
|
25923
|
-
alphaMode:"blend"});var handlers={};var addAxis=function addAxis(rgb,
|
|
25924
|
-
var _s2=(v0-d01*v1)/det;math.addVec3(P,math.mulVec3Scalar(D,_s2,dst),dst);return true;}else{return false;}};}();var initOffset=math.vec3();var tempVec3=math.vec3();handlers[arrowHandle.id]=handlers[shaftHandle.id]={setActivated:function setActivated(a){return bigArrowHead.visible=a;},initDragAction:function initDragAction(initCanvasPos){return closestPointOnAxis(initCanvasPos,initOffset)&&math.subVec3(initOffset,pos,initOffset)&&function(canvasPos){if(closestPointOnAxis(canvasPos,tempVec3)){math.subVec3(tempVec3,initOffset,tempVec3);setPos(tempVec3);if(
|
|
25942
|
+
alphaMode:"blend"});var handlers={};var addAxis=function addAxis(rgb,hoopRot){math.mulVec3Scalar(rgb,-1,math.vec3());var material=colorMaterial(rgb);var hoopMatrix=math.quaternionToRotationMat4(hoopRot,math.identityMat4());math.mulMat4(math.rotationMat4v(Math.PI,[0,1,0],math.mat4()),hoopMatrix,hoopMatrix);var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var scaledArrowMatrix=function scaledArrowMatrix(t,matR){var matT=math.translateMat4v(t,math.identityMat4());var ret=math.identityMat4();math.mulMat4(matT,matR,ret);math.mulMat4(hoopMatrix,ret,ret);return math.mulMat4(ret,scale,math.identityMat4());};var curve=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curve,material:material,matrix:hoopMatrix,pickable:false,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT);var rotateHandle=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curveHandle,material:pickableMaterial,matrix:hoopMatrix,pickable:true,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT);var arrow1=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:material,matrix:scaledArrowMatrix([.8,.07,0],math.rotationMat4v(180*math.DEGTORAD,[0,0,1],math.identityMat4())),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var arrow2=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:material,matrix:scaledArrowMatrix([.07,.8,0],math.rotationMat4v(90*math.DEGTORAD,[0,0,1],math.identityMat4())),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var hoop=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.hoop,material:material,highlighted:true,highlightMaterial:highlightMaterial(rgb,0.6),matrix:hoopMatrix,pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var axisRotation=math.quaternionToRotationMat4(math.vec3PairToQuaternion([0,1,0],rgb),math.identityMat4());math.mulMat4(math.rotationMat4v(Math.PI,[0,1,0],math.mat4()),axisRotation,axisRotation);var translatedAxisMatrix=function translatedAxisMatrix(yOffset){return math.mulMat4(axisRotation,math.translateMat4c(0,yOffset,0,math.identityMat4()),math.identityMat4());};var arrowMatrix=translatedAxisMatrix(arrowLength+.1);var shaftMatrix=translatedAxisMatrix(arrowLength/2);var arrow=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:material,matrix:arrowMatrix,pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var arrowHandle=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:pickableMaterial,matrix:arrowMatrix,pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var shaft=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:material,matrix:shaftMatrix,pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var shaftHandle=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:pickableMaterial,matrix:shaftMatrix,pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var bigArrowHead=rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:material,matrix:arrowMatrix,pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT);var localToWorldVec=function localToWorldVec(localVec,worldVec){return math.vec3ApplyQuaternion(rootNode.quaternion,localVec,worldVec);};var closestPointOnAxis=function(){var worldAxis=math.vec3();var org=math.vec3();var dir=math.vec3();return function(canvasPos,dst){localToWorldVec(rgb,worldAxis);var P=pos;var D=worldAxis;math.canvasPosToWorldRay(canvas,scene.camera.viewMatrix,scene.camera.projMatrix,scene.camera.projection,canvasPos,org,dir);var d01=math.dotVec3(D,dir);var v=math.subVec3(org,P,dst);var v0=math.dotVec3(v,D);var v1=math.dotVec3(v,dir);var det=1-d01*d01;if(Math.abs(det)>1e-10){// if lines are not parallel
|
|
25943
|
+
var _s2=(v0-d01*v1)/det;math.addVec3(P,math.mulVec3Scalar(D,_s2,dst),dst);return true;}else{return false;}};}();var initOffset=math.vec3();var tempVec3=math.vec3();handlers[arrowHandle.id]=handlers[shaftHandle.id]={setActivated:function setActivated(a){return bigArrowHead.visible=a;},initDragAction:function initDragAction(initCanvasPos){return closestPointOnAxis(initCanvasPos,initOffset)&&math.subVec3(initOffset,pos,initOffset)&&function(canvasPos){if(closestPointOnAxis(canvasPos,tempVec3)){math.subVec3(tempVec3,initOffset,tempVec3);setPos(tempVec3);if(_this141._sectionPlane){_this141._sectionPlane.pos=tempVec3;}}};}};handlers[rotateHandle.id]={setActivated:function setActivated(a){return hoop.visible=a;},initDragAction:function initDragAction(initCanvasPos){var rotationFromCanvasPos=function(){var planeCanvasPos=camera.projectWorldPos(pos);localToWorldVec(rgb,tempVec3);math.transformVec3(camera.normalMatrix,tempVec3,tempVec3);var axisCoeff=Math.sign(tempVec3[2]);return function(canvasPos){var dx=canvasPos[0]-planeCanvasPos[0];var dy=canvasPos[1]-planeCanvasPos[1];return axisCoeff*Math.atan2(-dy,dx);};}();var lastRotation=rotationFromCanvasPos(initCanvasPos);return function(canvasPos){var rotation=rotationFromCanvasPos(canvasPos);rootNode.rotate(rgb,(rotation-lastRotation)*180/Math.PI);if(_this141._sectionPlane){ignoreNextSectionPlaneDirUpdate=true;_this141._sectionPlane.quaternion=rootNode.quaternion;}lastRotation=rotation;};}};return{set visible(v){arrow.visible=arrowHandle.visible=shaft.visible=shaftHandle.visible=curve.visible=rotateHandle.visible=arrow1.visible=arrow2.visible=v;if(!v){bigArrowHead.visible=v;hoop.visible=v;}},set culled(c){arrow.culled=arrowHandle.culled=shaft.culled=shaftHandle.culled=curve.culled=rotateHandle.culled=arrow1.culled=arrow2.culled=c;if(!c){bigArrowHead.culled=c;hoop.culled=c;}}};};this._displayMeshes=[// Meshes that are always visible
|
|
25925
25944
|
rootNode.addChild(new Mesh(rootNode,{// plane
|
|
25926
25945
|
geometry:new ReadableGeometry(rootNode,{primitive:"triangles",positions:[0.5,0.5,0.0,0.5,-0.5,0.0,// 0
|
|
25927
25946
|
-0.5,-0.5,0.0,-0.5,0.5,0.0,// 1
|
|
@@ -25933,18 +25952,10 @@ highlightMaterial:new EmphasisMaterial(rootNode,{edges:false,edgeColor:[0.0,0.0,
|
|
|
25933
25952
|
geometry:new ReadableGeometry(rootNode,buildSphereGeometry({radius:0.05})),material:new PhongMaterial(rootNode,{diffuse:[0.0,0.0,0.0],emissive:[0,0,0],ambient:[0.0,0.0,0.0],specular:[.6,.6,.3],shininess:80}),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25934
25953
|
//
|
|
25935
25954
|
//----------------------------------------------------------------------------------------------------------
|
|
25936
|
-
addAxis([1,0,0],[1,0,0],[
|
|
25937
|
-
var lastDist=-1;var setRootNodeScale=function setRootNodeScale(size){return rootNode.scale=[size,size,size];};var onSceneTick=scene.on("tick",function(){var dist=Math.abs(math.distVec3(camera.eye,pos));if(camera.projection==="perspective"){if(dist!==lastDist){setRootNodeScale(0.07*dist*Math.tan(camera.perspective.fov*math.DEGTORAD));}}else if(camera.projection==="ortho"){setRootNodeScale(camera.ortho.scale/10);}lastDist=dist;});cleanups.push(function(){return scene.off(onSceneTick);});}var
|
|
25938
|
-
getTranslationPlane(worldAxis,planeNormal);getPointerPlaneIntersect(fromMouse,planeNormal,p1,1);// Ensure plane moves closer to camera so angles become workable
|
|
25939
|
-
getPointerPlaneIntersect(toMouse,planeNormal,p2,1);var dot=math.dotVec3(p1,worldAxis);p1[0]-=dot*worldAxis[0];p1[1]-=dot*worldAxis[1];p1[2]-=dot*worldAxis[2];dot=math.dotVec3(p2,worldAxis);p2[0]-=dot*worldAxis[0];p2[1]-=dot*worldAxis[1];p2[2]-=dot*worldAxis[2];}math.normalizeVec3(p1);math.normalizeVec3(p2);dot=math.dotVec3(p1,p2);dot=math.clamp(dot,-1.0,1.0);// Rounding errors cause dot to exceed allowed range
|
|
25940
|
-
var incDegrees=Math.acos(dot)*math.RADTODEG;math.cross3Vec3(p1,p2,c);if(math.dotVec3(c,worldAxis)<0.0){incDegrees=-incDegrees;}rootNode.rotate(baseAxis,incDegrees);if(self._sectionPlane){math.quaternionToMat4(rootNode.quaternion,mat);// << ---
|
|
25941
|
-
math.transformVec3(mat,[0,0,1],dir);ignoreNextSectionPlaneDirUpdate=true;self._sectionPlane.dir=dir;}};}();var getPointerPlaneIntersect=function(){var dir=math.vec4([0,0,0,1]);var matrix=math.mat4();return function(mouse,axis,dest,offset){offset=offset||0;dir[0]=mouse[0]/canvas.width*2.0-1.0;dir[1]=-(mouse[1]/canvas.height*2.0-1.0);dir[2]=0.0;dir[3]=1.0;math.mulMat4(camera.projMatrix,camera.viewMatrix,matrix);// Unproject norm device coords to view coords
|
|
25942
|
-
math.inverseMat4(matrix);math.transformVec4(matrix,dir,dir);math.mulVec4Scalar(dir,1.0/dir[3]);// This is now point A on the ray in world space
|
|
25943
|
-
var rayO=camera.eye;// The direction
|
|
25944
|
-
math.subVec4(dir,rayO,dir);var origin=self._sectionPlane.pos;// Plane origin:
|
|
25945
|
-
var d=-math.dotVec3(origin,axis)-offset;var dot=math.dotVec3(axis,dir);if(Math.abs(dot)>0.005){var t=-(math.dotVec3(axis,rayO)+d)/dot;math.mulVec3Scalar(dir,t,dest);math.addVec3(dest,rayO);math.subVec3(dest,origin,dest);return true;}return false;};}();{var deactivateActive=null;var currentDrag=null;cleanups.push(function(){if(currentDrag){currentDrag.cleanup();}});var _canvasPos3=math.vec2();var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.documentElement,canvas,vec2);};var pickHandler=function pickHandler(e){copyCanvasPos(e,_canvasPos3);var pickResult=viewer.scene.pick({canvasPos:_canvasPos3});var pickEntity=pickResult&&pickResult.entity;var pickId=pickEntity&&pickEntity.id;return pickId in handlers&&handlers[pickId];};var startDrag=function startDrag(event,matchesEvent){var handler=pickHandler(matchesEvent(event));if(handler){if(currentDrag){currentDrag.cleanup();}var dragAction=handler.initDragAction(_canvasPos3);if(dragAction){cameraControl.pointerEnabled=false;// or .active = false ?
|
|
25955
|
+
addAxis([1,0,0],math.vec3PairToQuaternion([1,0,0],[0,0,1])),addAxis([0,1,0],math.eulerToQuaternion([90,0,0],"XYZ")),addAxis([0,0,1],math.identityQuaternion())];var cleanups=[];{// Keep gizmo screen size constant
|
|
25956
|
+
var lastDist=-1;var setRootNodeScale=function setRootNodeScale(size){return rootNode.scale=[size,size,size];};var onSceneTick=scene.on("tick",function(){var dist=Math.abs(math.distVec3(camera.eye,pos));if(camera.projection==="perspective"){if(dist!==lastDist){setRootNodeScale(0.07*dist*Math.tan(camera.perspective.fov*math.DEGTORAD));}}else if(camera.projection==="ortho"){setRootNodeScale(camera.ortho.scale/10);}lastDist=dist;});cleanups.push(function(){return scene.off(onSceneTick);});}{var deactivateActive=null;var currentDrag=null;cleanups.push(function(){if(currentDrag){currentDrag.cleanup();}});var _canvasPos3=math.vec2();var copyCanvasPos=function copyCanvasPos(event,vec2){vec2[0]=event.clientX;vec2[1]=event.clientY;transformToNode(canvas.ownerDocument.documentElement,canvas,vec2);};var pickHandler=function pickHandler(e){copyCanvasPos(e,_canvasPos3);var pickResult=viewer.scene.pick({canvasPos:_canvasPos3});var pickEntity=pickResult&&pickResult.entity;var pickId=pickEntity&&pickEntity.id;return pickId in handlers&&handlers[pickId];};var startDrag=function startDrag(event,matchesEvent){var handler=pickHandler(matchesEvent(event));if(handler){if(currentDrag){currentDrag.cleanup();}var dragAction=handler.initDragAction(_canvasPos3);if(dragAction){cameraControl.pointerEnabled=false;// or .active = false ?
|
|
25946
25957
|
handler.setActivated(true);currentDrag={onChange:function onChange(event){var e=matchesEvent(event);if(e){copyCanvasPos(e,_canvasPos3);dragAction(_canvasPos3);}},cleanup:function cleanup(){currentDrag=null;cameraControl.pointerEnabled=true;// or .active = true ?
|
|
25947
|
-
handler.setActivated(false);}};}}};var addCanvasEventListener=function addCanvasEventListener(type,listener){canvas.addEventListener(type,listener);cleanups.push(function(){return canvas.removeEventListener(type,listener);});};addCanvasEventListener("mousedown",function(e){e.preventDefault();if(e.which===1){startDrag(e,function(event){return event.which===1&&event;});}});addCanvasEventListener("mousemove",function(e){if(currentDrag){currentDrag.onChange(e);}else{if(deactivateActive){deactivateActive();}var handler=pickHandler(e);if(handler){handler.setActivated(true);deactivateActive=function deactivateActive(){return handler.setActivated(false);};}else{deactivateActive=null;}}});addCanvasEventListener("mouseup",function(e){if(currentDrag){currentDrag.onChange(e);currentDrag.cleanup();}});addCanvasEventListener("touchstart",function(event){event.preventDefault();if(event.touches.length===1){var touchStartId=event.touches[0].identifier;startDrag(event,function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});});}});addCanvasEventListener("touchmove",function(event){event.preventDefault();currentDrag&¤tDrag.onChange(event);});addCanvasEventListener("touchend",function(event){event.preventDefault();if(currentDrag){currentDrag.onChange(event);currentDrag.cleanup();}});}this._unbindSectionPlane=function(){};this.__setSectionPlane=function(sectionPlane){_this141.id=sectionPlane.id;_this141._sectionPlane=sectionPlane;var setPosFromSectionPlane=function setPosFromSectionPlane(){return setPos(sectionPlane.pos);};var setDirFromSectionPlane=function setDirFromSectionPlane(){return rootNode.quaternion=
|
|
25958
|
+
handler.setActivated(false);}};}}};var addCanvasEventListener=function addCanvasEventListener(type,listener){canvas.addEventListener(type,listener);cleanups.push(function(){return canvas.removeEventListener(type,listener);});};addCanvasEventListener("mousedown",function(e){e.preventDefault();if(e.which===1){startDrag(e,function(event){return event.which===1&&event;});}});addCanvasEventListener("mousemove",function(e){if(currentDrag){currentDrag.onChange(e);}else{if(deactivateActive){deactivateActive();}var handler=pickHandler(e);if(handler){handler.setActivated(true);deactivateActive=function deactivateActive(){return handler.setActivated(false);};}else{deactivateActive=null;}}});addCanvasEventListener("mouseup",function(e){if(currentDrag){currentDrag.onChange(e);currentDrag.cleanup();}});addCanvasEventListener("touchstart",function(event){event.preventDefault();if(event.touches.length===1){var touchStartId=event.touches[0].identifier;startDrag(event,function(event){return _toConsumableArray(event.changedTouches).find(function(e){return e.identifier===touchStartId;});});}});addCanvasEventListener("touchmove",function(event){event.preventDefault();currentDrag&¤tDrag.onChange(event);});addCanvasEventListener("touchend",function(event){event.preventDefault();if(currentDrag){currentDrag.onChange(event);currentDrag.cleanup();}});}this._unbindSectionPlane=function(){};this.__setSectionPlane=function(sectionPlane){_this141.id=sectionPlane.id;_this141._sectionPlane=sectionPlane;var setPosFromSectionPlane=function setPosFromSectionPlane(){return setPos(sectionPlane.pos);};var setDirFromSectionPlane=function setDirFromSectionPlane(){return rootNode.quaternion=sectionPlane.quaternion;};setPosFromSectionPlane();setDirFromSectionPlane();var onSectionPlanePos=sectionPlane.on("pos",setPosFromSectionPlane);var onSectionPlaneDir=sectionPlane.on("dir",function(){if(!ignoreNextSectionPlaneDirUpdate){setDirFromSectionPlane();}else{ignoreNextSectionPlaneDirUpdate=false;}});_this141._unbindSectionPlane=function(){_this141.id=null;_this141._sectionPlane=null;sectionPlane.off(onSectionPlanePos);sectionPlane.off(onSectionPlaneDir);_this141._unbindSectionPlane=function(){};};};this.__destroy=function(){cleanups.forEach(function(c){return c();});_this141._unbindSectionPlane();rootNode.destroy();_this141._displayMeshes=[];for(var id in handlers){delete handlers[id];}};}_createClass(Control,[{key:"_destroy",value:function _destroy(){this.__destroy();}/**
|
|
25948
25959
|
* Called by SectionPlanesPlugin to assign this Control to a SectionPlane.
|
|
25949
25960
|
* SectionPlanesPlugin keeps SectionPlaneControls in a reuse pool.
|
|
25950
25961
|
* Call with a null or undefined value to disconnect the Control ffrom whatever SectionPlane it was assigned to.
|
|
@@ -26622,7 +26633,7 @@ imagePos[0]=Math.floor(storeyMap.width-(worldPos[0]-xmin)*ratioX);imagePos[1]=Ma
|
|
|
26622
26633
|
* Gets Storeys in a list, spatially sorted on the vertical World axis, the lowest Storey first.
|
|
26623
26634
|
*
|
|
26624
26635
|
* @returns {null}
|
|
26625
|
-
*/},{key:"storeysList",get:function get(){if(!this._storeysList){this._storeysList=Object.values(this.storeys);this._storeysList.sort(this._getSpatialSortFunc());}return this._storeysList;}},{key:"_getSpatialSortFunc",value:function _getSpatialSortFunc(){var _this148=this;var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=function(storey1,storey2){var idx=0;if(camera.xUp){idx=0;}else if(camera.yUp){idx=1;}else{idx=2;}var metaScene=_this148.viewer.metaScene;var storey1MetaObject=metaScene.metaObjects[storey1.storeyId];var storey2MetaObject=metaScene.metaObjects[storey2.storeyId];if(storey1MetaObject&&storey1MetaObject.attributes&&storey1MetaObject.attributes.elevation!==undefined&&storey2MetaObject&&storey2MetaObject.attributes&&storey2MetaObject.attributes.elevation!==undefined){var elevation1=Number.parseFloat(storey1MetaObject.attributes.elevation);var elevation2=Number.parseFloat(storey2MetaObject.attributes.elevation);if(elevation1>elevation2){return-1;}if(elevation1<elevation2){return 1;}return 0;}else{if(storey1.aabb[idx]>storey2.aabb[idx]){return-1;}if(storey1.aabb[idx]<storey2.aabb[idx]){return 1;}return 0;}});}},{key:"_filterStoreys",value:function _filterStoreys(modelId){return Object.fromEntries(Object.entries(this.storeys).filter(function(
|
|
26636
|
+
*/},{key:"storeysList",get:function get(){if(!this._storeysList){this._storeysList=Object.values(this.storeys);this._storeysList.sort(this._getSpatialSortFunc());}return this._storeysList;}},{key:"_getSpatialSortFunc",value:function _getSpatialSortFunc(){var _this148=this;var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=function(storey1,storey2){var idx=0;if(camera.xUp){idx=0;}else if(camera.yUp){idx=1;}else{idx=2;}var metaScene=_this148.viewer.metaScene;var storey1MetaObject=metaScene.metaObjects[storey1.storeyId];var storey2MetaObject=metaScene.metaObjects[storey2.storeyId];if(storey1MetaObject&&storey1MetaObject.attributes&&storey1MetaObject.attributes.elevation!==undefined&&storey2MetaObject&&storey2MetaObject.attributes&&storey2MetaObject.attributes.elevation!==undefined){var elevation1=Number.parseFloat(storey1MetaObject.attributes.elevation);var elevation2=Number.parseFloat(storey2MetaObject.attributes.elevation);if(elevation1>elevation2){return-1;}if(elevation1<elevation2){return 1;}return 0;}else{if(storey1.aabb[idx]>storey2.aabb[idx]){return-1;}if(storey1.aabb[idx]<storey2.aabb[idx]){return 1;}return 0;}});}},{key:"_filterStoreys",value:function _filterStoreys(modelId){return Object.fromEntries(Object.entries(this.storeys).filter(function(_ref23){var _ref24=_slicedToArray(_ref23,2),_=_ref24[0],value=_ref24[1];return value.modelId===modelId;}));}}]);return StoreyViewsPlugin;}(Plugin);var zeroVec=new Float64Array([0,0,1]);var quat=new Float64Array(4);/**
|
|
26626
26637
|
* Controls a {@link SectionPlane} with mouse and touch input.
|
|
26627
26638
|
*/var FaceAlignedSectionPlanesControl=/*#__PURE__*/function(){/** @private */function FaceAlignedSectionPlanesControl(plugin){_classCallCheck(this,FaceAlignedSectionPlanesControl);/**
|
|
26628
26639
|
* ID of this FaceAlignedSectionPlanesControl.
|
|
@@ -27594,7 +27605,9 @@ addMesh(modelNode,positions,normals,colors,material,options);}function addMesh(m
|
|
|
27594
27605
|
* @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
|
|
27595
27606
|
* @param {Boolean} [cfg.showIndeterminate=false] When true, will show indeterminate state for checkboxes when some but not all child nodes are checked
|
|
27596
27607
|
* @param {Boolean} [cfg.showProjectNode=false] When true, will show top level project node when hierarchy is set to "storeys"
|
|
27597
|
-
|
|
27608
|
+
* @param {Function} [cfg.elevationSortFunction] Optional function to replace the default elevation sort function. The function should take two nodes and return -1, 0 or 1.
|
|
27609
|
+
* @param {Function} [cfg.defaultSortFunction] Optional function to replace the default sort function. The function should take two nodes and return -1, 0 or 1.
|
|
27610
|
+
*/function TreeViewPlugin(viewer){var _cfg$showIndeterminat,_cfg$showProjectNode,_cfg$elevationSortFun,_cfg$defaultSortFunct;var _this157;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,TreeViewPlugin);_this157=_super166.call(this,"TreeViewPlugin",viewer);/**
|
|
27598
27611
|
* Contains messages for any errors found while last rebuilding this TreeView.
|
|
27599
27612
|
* @type {String[]}
|
|
27600
27613
|
*/_this157.errors=[];/**
|
|
@@ -27603,7 +27616,7 @@ addMesh(modelNode,positions,normals,colors,material,options);}function addMesh(m
|
|
|
27603
27616
|
*/_this157.valid=true;var containerElement=cfg.containerElement||document.getElementById(cfg.containerElementId);if(!(containerElement instanceof HTMLElement)){_this157.error("Mandatory config expected: valid containerElementId or containerElement");return _possibleConstructorReturn(_this157);}for(var _i538=0;;_i538++){if(!treeViews[_i538]){treeViews[_i538]=_assertThisInitialized(_this157);_this157._index=_i538;_this157._id="tree-".concat(_i538);break;}}_this157._containerElement=containerElement;_this157._metaModels={};_this157._autoAddModels=cfg.autoAddModels!==false;_this157._autoExpandDepth=cfg.autoExpandDepth||0;_this157._sortNodes=cfg.sortNodes!==false;_this157._viewer=viewer;_this157._rootElement=null;_this157._muteSceneEvents=false;_this157._muteTreeEvents=false;_this157._rootNodes=[];_this157._objectNodes={};// Object ID -> Node
|
|
27604
27617
|
_this157._nodeNodes={};// Node ID -> Node
|
|
27605
27618
|
_this157._rootNames={};// Node ID -> Root name
|
|
27606
|
-
_this157._sortNodes=cfg.sortNodes;_this157._pruneEmptyNodes=cfg.pruneEmptyNodes;_this157._showListItemElementId=null;_this157._renderService=cfg.renderService||new RenderService();_this157._showIndeterminate=(_cfg$showIndeterminat=cfg.showIndeterminate)!==null&&_cfg$showIndeterminat!==void 0?_cfg$showIndeterminat:false;_this157._showProjectNode=(_cfg$showProjectNode=cfg.showProjectNode)!==null&&_cfg$showProjectNode!==void 0?_cfg$showProjectNode:false;if(!_this157._renderService){throw new Error('TreeViewPlugin: no render service set');}_this157._containerElement.oncontextmenu=function(e){e.preventDefault();};_this157._onObjectVisibility=_this157._viewer.scene.on("objectVisibility",function(entity){if(_this157._muteSceneEvents){return;}var objectId=entity.id;var node=_this157._objectNodes[objectId];if(!node){return;// Not in this tree
|
|
27619
|
+
_this157._sortNodes=cfg.sortNodes;_this157._pruneEmptyNodes=cfg.pruneEmptyNodes;_this157._showListItemElementId=null;_this157._renderService=cfg.renderService||new RenderService();_this157._showIndeterminate=(_cfg$showIndeterminat=cfg.showIndeterminate)!==null&&_cfg$showIndeterminat!==void 0?_cfg$showIndeterminat:false;_this157._showProjectNode=(_cfg$showProjectNode=cfg.showProjectNode)!==null&&_cfg$showProjectNode!==void 0?_cfg$showProjectNode:false;_this157._elevationSortFunction=(_cfg$elevationSortFun=cfg.elevationSortFunction)!==null&&_cfg$elevationSortFun!==void 0?_cfg$elevationSortFun:undefined;_this157._defaultSortFunction=(_cfg$defaultSortFunct=cfg.defaultSortFunction)!==null&&_cfg$defaultSortFunct!==void 0?_cfg$defaultSortFunct:undefined;if(!_this157._renderService){throw new Error('TreeViewPlugin: no render service set');}_this157._containerElement.oncontextmenu=function(e){e.preventDefault();};_this157._onObjectVisibility=_this157._viewer.scene.on("objectVisibility",function(entity){if(_this157._muteSceneEvents){return;}var objectId=entity.id;var node=_this157._objectNodes[objectId];if(!node){return;// Not in this tree
|
|
27607
27620
|
}var visible=entity.visible;var updated=visible!==node.checked;if(!updated){return;}_this157._muteTreeEvents=true;node.checked=visible;if(visible){node.numVisibleEntities++;}else{node.numVisibleEntities--;}_this157._renderService.setCheckbox(node.nodeId,visible);var parent=node.parent;while(parent){parent.checked=visible;if(visible){parent.numVisibleEntities++;}else{parent.numVisibleEntities--;}var indeterminate=_this157._showIndeterminate&&parent.numVisibleEntities>0&&parent.numVisibleEntities<parent.numEntities;_this157._renderService.setCheckbox(parent.nodeId,parent.numVisibleEntities>0,indeterminate);parent=parent.parent;}_this157._muteTreeEvents=false;});_this157._onObjectXrayed=_this157._viewer.scene.on('objectXRayed',function(entity){if(_this157._muteSceneEvents){return;}var objectId=entity.id;var node=_this157._objectNodes[objectId];if(!node){return;// Not in this tree
|
|
27608
27621
|
}_this157._muteTreeEvents=true;var xrayed=entity.xrayed;var updated=xrayed!==node.xrayed;if(!updated){return;}node.xrayed=xrayed;_this157._renderService.setXRayed(node.nodeId,xrayed);_this157._muteTreeEvents=false;});_this157._switchExpandHandler=function(event){event.preventDefault();event.stopPropagation();var switchElement=event.target;_this157._expandSwitchElement(switchElement);};_this157._switchCollapseHandler=function(event){event.preventDefault();event.stopPropagation();var switchElement=event.target;_this157._collapseSwitchElement(switchElement);};_this157._checkboxChangeHandler=function(event){if(_this157._muteTreeEvents){return;}_this157._muteSceneEvents=true;var checkbox=event.target;var visible=_this157._renderService.isChecked(checkbox);var nodeId=_this157._renderService.getIdFromCheckbox(checkbox);var checkedNode=_this157._nodeNodes[nodeId];var objects=_this157._viewer.scene.objects;var numUpdated=0;_this157._withNodeTree(checkedNode,function(node){var objectId=node.objectId;var entity=objects[objectId];var isLeaf=node.children.length===0;node.numVisibleEntities=visible?node.numEntities:0;if(isLeaf&&visible!==node.checked){numUpdated++;}node.checked=visible;_this157._renderService.setCheckbox(node.nodeId,visible);if(entity){entity.visible=visible;}});var parent=checkedNode.parent;while(parent){parent.checked=visible;if(visible){parent.numVisibleEntities+=numUpdated;}else{parent.numVisibleEntities-=numUpdated;}var indeterminate=_this157._showIndeterminate&&parent.numVisibleEntities>0&&parent.numVisibleEntities<parent.numEntities;_this157._renderService.setCheckbox(parent.nodeId,parent.numVisibleEntities>0,indeterminate);parent=parent.parent;}_this157._muteSceneEvents=false;};_this157._hierarchy=cfg.hierarchy||"containment";_this157._autoExpandDepth=cfg.autoExpandDepth||0;if(_this157._autoAddModels){var modelIds=Object.keys(_this157.viewer.metaScene.metaModels);for(var _i539=0,len=modelIds.length;_i539<len;_i539++){var modelId=modelIds[_i539];var metaModel=_this157.viewer.metaScene.metaModels[modelId];if(metaModel.finalized){_this157.addModel(modelId);}}_this157.viewer.scene.on("modelLoaded",function(modelId){if(_this157.viewer.metaScene.metaModels[modelId]){_this157.addModel(modelId);}});}_this157.hierarchy=cfg.hierarchy;return _this157;}/**
|
|
27609
27622
|
* Sets how the nodes are organized within this tree view.
|
|
@@ -27708,7 +27721,7 @@ _this157._sortNodes=cfg.sortNodes;_this157._pruneEmptyNodes=cfg.pruneEmptyNodes;
|
|
|
27708
27721
|
// // errors.push("Can't build storeys hierarchy: no IfcBuildingStoreys found");
|
|
27709
27722
|
// }
|
|
27710
27723
|
// }
|
|
27711
|
-
return true;}},{key:"_createEnabledNodes",value:function _createEnabledNodes(){if(this._pruneEmptyNodes){this._findEmptyNodes();}switch(this._hierarchy){case"storeys":this._createStoreysNodes();if(this._rootNodes.length===0){this.error("Failed to build storeys hierarchy");}break;case"types":this._createTypesNodes();break;case"containment":default:this._createContainmentNodes();}if(this._sortNodes){this._doSortNodes();}this._synchNodesToEntities();this._createTrees();this.expandToDepth(this._autoExpandDepth);}},{key:"_createDisabledNodes",value:function _createDisabledNodes(){var rootNode=this._renderService.createRootNode();this._rootElement=rootNode;this._containerElement.appendChild(rootNode);var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var objectId in rootMetaObjects){var rootMetaObject=rootMetaObjects[objectId];var metaObjectType=rootMetaObject.type;var metaObjectName=rootMetaObject.name;var rootName=metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType;var childNode=this._renderService.createDisabledNodeElement(rootName);rootNode.appendChild(childNode);}}},{key:"_findEmptyNodes",value:function _findEmptyNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var objectId in rootMetaObjects){this._findEmptyNodes2(rootMetaObjects[objectId]);}}},{key:"_findEmptyNodes2",value:function _findEmptyNodes2(metaObject){var countEntities=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var viewer=this.viewer;var scene=viewer.scene;var children=metaObject.children;var objectId=metaObject.id;var entity=scene.objects[objectId];metaObject._countEntities=0;if(entity){metaObject._countEntities++;}if(children){for(var _i544=0,len=children.length;_i544<len;_i544++){var childMetaObject=children[_i544];childMetaObject._countEntities=this._findEmptyNodes2(childMetaObject);metaObject._countEntities+=childMetaObject._countEntities;}}return metaObject._countEntities;}},{key:"_createStoreysNodes",value:function _createStoreysNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createStoreysNodes2(rootMetaObjects[id],null,null,null,null);}}},{key:"_createStoreysNodes2",value:function _createStoreysNodes2(metaObject,projectNode,buildingNode,storeyNode,typeNodes){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name;var children=metaObject.children;var objectId=metaObject.id;if(this._showProjectNode&&metaObjectType==='IfcProject'){projectNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:null,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};this._rootNodes.push(projectNode);this._objectNodes[projectNode.objectId]=projectNode;this._nodeNodes[projectNode.nodeId]=projectNode;}else if(metaObjectType==="IfcBuilding"){buildingNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:projectNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};if(projectNode){projectNode.children.push(buildingNode);}else{this._rootNodes.push(buildingNode);}this._objectNodes[buildingNode.objectId]=buildingNode;this._nodeNodes[buildingNode.nodeId]=buildingNode;}else if(metaObjectType==="IfcBuildingStorey"){if(!buildingNode){this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");return;}storeyNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:buildingNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};buildingNode.children.push(storeyNode);this._objectNodes[storeyNode.objectId]=storeyNode;this._nodeNodes[storeyNode.nodeId]=storeyNode;typeNodes={};}else{if(storeyNode){var objects=this._viewer.scene.objects;var object=objects[objectId];if(object){typeNodes=typeNodes||{};var typeNode=typeNodes[metaObjectType];if(!typeNode){typeNode={nodeId:"".concat(this._id,"-").concat(storeyNode.objectId,"-").concat(metaObjectType),objectId:"".concat(storeyNode.objectId,"-").concat(metaObjectType),title:metaObjectType,type:metaObjectType,parent:storeyNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};storeyNode.children.push(typeNode);this._objectNodes[typeNode.objectId]=typeNode;this._nodeNodes[typeNode.nodeId]=typeNode;typeNodes[metaObjectType]=typeNode;}var _node6={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:typeNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};typeNode.children.push(_node6);this._objectNodes[_node6.objectId]=_node6;this._nodeNodes[_node6.nodeId]=_node6;}}}if(children){for(var _i545=0,len=children.length;_i545<len;_i545++){var childMetaObject=children[_i545];this._createStoreysNodes2(childMetaObject,projectNode,buildingNode,storeyNode,typeNodes);}}}},{key:"_createTypesNodes",value:function _createTypesNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createTypesNodes2(rootMetaObjects[id],null,null);}}},{key:"_createTypesNodes2",value:function _createTypesNodes2(metaObject,rootNode,typeNodes){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name;var children=metaObject.children;var objectId=metaObject.id;if(!metaObject.parent){rootNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:null,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};this._rootNodes.push(rootNode);this._objectNodes[rootNode.objectId]=rootNode;this._nodeNodes[rootNode.nodeId]=rootNode;typeNodes={};}else{if(rootNode){var objects=this._viewer.scene.objects;var object=objects[objectId];if(object){var typeNode=typeNodes[metaObjectType];if(!typeNode){typeNode={nodeId:"".concat(this._id,"-").concat(rootNode.objectId,"-").concat(metaObjectType),objectId:"".concat(rootNode.objectId,"-").concat(metaObjectType),title:metaObjectType,type:metaObjectType,parent:rootNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};rootNode.children.push(typeNode);this._objectNodes[typeNode.objectId]=typeNode;this._nodeNodes[typeNode.nodeId]=typeNode;typeNodes[metaObjectType]=typeNode;}var _node7={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:typeNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};typeNode.children.push(_node7);this._objectNodes[_node7.objectId]=_node7;this._nodeNodes[_node7.nodeId]=_node7;}}}if(children){for(var _i546=0,len=children.length;_i546<len;_i546++){var childMetaObject=children[_i546];this._createTypesNodes2(childMetaObject,rootNode,typeNodes);}}}},{key:"_createContainmentNodes",value:function _createContainmentNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createContainmentNodes2(rootMetaObjects[id],null);}}},{key:"_createContainmentNodes2",value:function _createContainmentNodes2(metaObject,parent){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name||metaObjectType;var children=metaObject.children;var objectId=metaObject.id;var node={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:!parent?metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||metaObjectName:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:parent,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};if(parent){parent.children.push(node);}else{this._rootNodes.push(node);}this._objectNodes[node.objectId]=node;this._nodeNodes[node.nodeId]=node;if(children){for(var _i547=0,len=children.length;_i547<len;_i547++){var childMetaObject=children[_i547];this._createContainmentNodes2(childMetaObject,node);}}}},{key:"_doSortNodes",value:function _doSortNodes(){for(var _i548=0,len=this._rootNodes.length;_i548<len;_i548++){var rootNode=this._rootNodes[_i548];this._sortChildren(rootNode);}}},{key:"_sortChildren",value:function _sortChildren(node){var children=node.children;if(!children||children.length===0){return;}var firstChild=children[0];if((this._hierarchy==="storeys"||this._hierarchy==="containment")&&firstChild.type==="IfcBuildingStorey"){children.sort(this._getSpatialSortFunc());}else{children.sort(this._alphaSortFunc);}for(var _i549=0,len=children.length;_i549<len;_i549++){var _node8=children[_i549];this._sortChildren(_node8);}}},{key:"_getSpatialSortFunc",value:function _getSpatialSortFunc(){var _this160=this;var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=function(storey1,storey2){if(camera.xUp);else if(camera.yUp);else;var metaScene=_this160.viewer.metaScene;var storey1MetaObject=metaScene.metaObjects[storey1.objectId];var storey2MetaObject=metaScene.metaObjects[storey2.objectId];if(storey1MetaObject&&storey1MetaObject.attributes&&storey1MetaObject.attributes.elevation!==undefined&&storey2MetaObject&&storey2MetaObject.attributes&&storey2MetaObject.attributes.elevation!==undefined){var elevation1=Number.parseFloat(storey1MetaObject.attributes.elevation);var elevation2=Number.parseFloat(storey2MetaObject.attributes.elevation);if(elevation1>elevation2){return-1;}if(elevation1<elevation2){return 1;}return 0;}else{return 0;}});}},{key:"_alphaSortFunc",value:function _alphaSortFunc(node1,node2){var title1=node1.title.toUpperCase();// FIXME: Should be case sensitive?
|
|
27724
|
+
return true;}},{key:"_createEnabledNodes",value:function _createEnabledNodes(){if(this._pruneEmptyNodes){this._findEmptyNodes();}switch(this._hierarchy){case"storeys":this._createStoreysNodes();if(this._rootNodes.length===0){this.error("Failed to build storeys hierarchy");}break;case"types":this._createTypesNodes();break;case"containment":default:this._createContainmentNodes();}if(this._sortNodes){this._doSortNodes();}this._synchNodesToEntities();this._createTrees();this.expandToDepth(this._autoExpandDepth);}},{key:"_createDisabledNodes",value:function _createDisabledNodes(){var rootNode=this._renderService.createRootNode();this._rootElement=rootNode;this._containerElement.appendChild(rootNode);var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var objectId in rootMetaObjects){var rootMetaObject=rootMetaObjects[objectId];var metaObjectType=rootMetaObject.type;var metaObjectName=rootMetaObject.name;var rootName=metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType;var childNode=this._renderService.createDisabledNodeElement(rootName);rootNode.appendChild(childNode);}}},{key:"_findEmptyNodes",value:function _findEmptyNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var objectId in rootMetaObjects){this._findEmptyNodes2(rootMetaObjects[objectId]);}}},{key:"_findEmptyNodes2",value:function _findEmptyNodes2(metaObject){var countEntities=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var viewer=this.viewer;var scene=viewer.scene;var children=metaObject.children;var objectId=metaObject.id;var entity=scene.objects[objectId];metaObject._countEntities=0;if(entity){metaObject._countEntities++;}if(children){for(var _i544=0,len=children.length;_i544<len;_i544++){var childMetaObject=children[_i544];childMetaObject._countEntities=this._findEmptyNodes2(childMetaObject);metaObject._countEntities+=childMetaObject._countEntities;}}return metaObject._countEntities;}},{key:"_createStoreysNodes",value:function _createStoreysNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createStoreysNodes2(rootMetaObjects[id],null,null,null,null);}}},{key:"_createStoreysNodes2",value:function _createStoreysNodes2(metaObject,projectNode,buildingNode,storeyNode,typeNodes){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name;var children=metaObject.children;var objectId=metaObject.id;if(this._showProjectNode&&metaObjectType==='IfcProject'){projectNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:null,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};this._rootNodes.push(projectNode);this._objectNodes[projectNode.objectId]=projectNode;this._nodeNodes[projectNode.nodeId]=projectNode;}else if(metaObjectType==="IfcBuilding"){buildingNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:projectNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};if(projectNode){projectNode.children.push(buildingNode);}else{this._rootNodes.push(buildingNode);}this._objectNodes[buildingNode.objectId]=buildingNode;this._nodeNodes[buildingNode.nodeId]=buildingNode;}else if(metaObjectType==="IfcBuildingStorey"){if(!buildingNode){this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");return;}storeyNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:buildingNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};buildingNode.children.push(storeyNode);this._objectNodes[storeyNode.objectId]=storeyNode;this._nodeNodes[storeyNode.nodeId]=storeyNode;typeNodes={};}else{if(storeyNode){var objects=this._viewer.scene.objects;var object=objects[objectId];if(object){typeNodes=typeNodes||{};var typeNode=typeNodes[metaObjectType];if(!typeNode){typeNode={nodeId:"".concat(this._id,"-").concat(storeyNode.objectId,"-").concat(metaObjectType),objectId:"".concat(storeyNode.objectId,"-").concat(metaObjectType),title:metaObjectType,type:metaObjectType,parent:storeyNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};storeyNode.children.push(typeNode);this._objectNodes[typeNode.objectId]=typeNode;this._nodeNodes[typeNode.nodeId]=typeNode;typeNodes[metaObjectType]=typeNode;}var _node6={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:typeNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};typeNode.children.push(_node6);this._objectNodes[_node6.objectId]=_node6;this._nodeNodes[_node6.nodeId]=_node6;}}}if(children){for(var _i545=0,len=children.length;_i545<len;_i545++){var childMetaObject=children[_i545];this._createStoreysNodes2(childMetaObject,projectNode,buildingNode,storeyNode,typeNodes);}}}},{key:"_createTypesNodes",value:function _createTypesNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createTypesNodes2(rootMetaObjects[id],null,null);}}},{key:"_createTypesNodes2",value:function _createTypesNodes2(metaObject,rootNode,typeNodes){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name;var children=metaObject.children;var objectId=metaObject.id;if(!metaObject.parent){rootNode={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||(metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType),type:metaObjectType,parent:null,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};this._rootNodes.push(rootNode);this._objectNodes[rootNode.objectId]=rootNode;this._nodeNodes[rootNode.nodeId]=rootNode;typeNodes={};}else{if(rootNode){var objects=this._viewer.scene.objects;var object=objects[objectId];if(object){var typeNode=typeNodes[metaObjectType];if(!typeNode){typeNode={nodeId:"".concat(this._id,"-").concat(rootNode.objectId,"-").concat(metaObjectType),objectId:"".concat(rootNode.objectId,"-").concat(metaObjectType),title:metaObjectType,type:metaObjectType,parent:rootNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};rootNode.children.push(typeNode);this._objectNodes[typeNode.objectId]=typeNode;this._nodeNodes[typeNode.nodeId]=typeNode;typeNodes[metaObjectType]=typeNode;}var _node7={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:typeNode,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};typeNode.children.push(_node7);this._objectNodes[_node7.objectId]=_node7;this._nodeNodes[_node7.nodeId]=_node7;}}}if(children){for(var _i546=0,len=children.length;_i546<len;_i546++){var childMetaObject=children[_i546];this._createTypesNodes2(childMetaObject,rootNode,typeNodes);}}}},{key:"_createContainmentNodes",value:function _createContainmentNodes(){var rootMetaObjects=this._viewer.metaScene.rootMetaObjects;for(var id in rootMetaObjects){this._createContainmentNodes2(rootMetaObjects[id],null);}}},{key:"_createContainmentNodes2",value:function _createContainmentNodes2(metaObject,parent){if(this._pruneEmptyNodes&&metaObject._countEntities===0){return;}var metaObjectType=metaObject.type;var metaObjectName=metaObject.name||metaObjectType;var children=metaObject.children;var objectId=metaObject.id;var node={nodeId:"".concat(this._id,"-").concat(objectId),objectId:objectId,title:!parent?metaObject.metaModels.length===0?metaObjectName:this._rootNames[metaObject.metaModels[0].id]||metaObjectName:metaObjectName&&metaObjectName!==""&&metaObjectName!=="Undefined"&&metaObjectName!=="Default"?metaObjectName:metaObjectType,type:metaObjectType,parent:parent,numEntities:0,numVisibleEntities:0,checked:false,xrayed:false,children:[]};if(parent){parent.children.push(node);}else{this._rootNodes.push(node);}this._objectNodes[node.objectId]=node;this._nodeNodes[node.nodeId]=node;if(children){for(var _i547=0,len=children.length;_i547<len;_i547++){var childMetaObject=children[_i547];this._createContainmentNodes2(childMetaObject,node);}}}},{key:"_doSortNodes",value:function _doSortNodes(){for(var _i548=0,len=this._rootNodes.length;_i548<len;_i548++){var rootNode=this._rootNodes[_i548];this._sortChildren(rootNode);}}},{key:"_sortChildren",value:function _sortChildren(node){var children=node.children;if(!children||children.length===0){return;}var firstChild=children[0];if((this._hierarchy==="storeys"||this._hierarchy==="containment")&&firstChild.type==="IfcBuildingStorey"){if(this._elevationSortFunction)children.sort(this._elevationSortFunction);else children.sort(this._getSpatialSortFunc());}else{if(this._defaultSortFunction)children.sort(this._defaultSortFunction);else children.sort(this._alphaSortFunc);}for(var _i549=0,len=children.length;_i549<len;_i549++){var _node8=children[_i549];this._sortChildren(_node8);}}},{key:"_getSpatialSortFunc",value:function _getSpatialSortFunc(){var _this160=this;var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;return this._spatialSortFunc||(this._spatialSortFunc=function(storey1,storey2){if(camera.xUp);else if(camera.yUp);else;var metaScene=_this160.viewer.metaScene;var storey1MetaObject=metaScene.metaObjects[storey1.objectId];var storey2MetaObject=metaScene.metaObjects[storey2.objectId];if(storey1MetaObject&&storey1MetaObject.attributes&&storey1MetaObject.attributes.elevation!==undefined&&storey2MetaObject&&storey2MetaObject.attributes&&storey2MetaObject.attributes.elevation!==undefined){var elevation1=Number.parseFloat(storey1MetaObject.attributes.elevation);var elevation2=Number.parseFloat(storey2MetaObject.attributes.elevation);if(elevation1>elevation2){return-1;}if(elevation1<elevation2){return 1;}return 0;}else{return 0;}});}},{key:"_alphaSortFunc",value:function _alphaSortFunc(node1,node2){var title1=node1.title.toUpperCase();// FIXME: Should be case sensitive?
|
|
27712
27725
|
var title2=node2.title.toUpperCase();if(title1<title2){return-1;}if(title1>title2){return 1;}return 0;}},{key:"_synchNodesToEntities",value:function _synchNodesToEntities(){var objectIds=Object.keys(this.viewer.metaScene.metaObjects);var metaObjects=this._viewer.metaScene.metaObjects;var objects=this._viewer.scene.objects;for(var _i550=0,len=objectIds.length;_i550<len;_i550++){var objectId=objectIds[_i550];var metaObject=metaObjects[objectId];if(metaObject){var _node9=this._objectNodes[objectId];if(_node9){var entity=objects[objectId];if(entity){var visible=entity.visible;_node9.numEntities=1;_node9.xrayed=entity.xrayed;if(visible){_node9.numVisibleEntities=1;_node9.checked=true;}else{_node9.numVisibleEntities=0;_node9.checked=false;}var parent=_node9.parent;// Synch parents
|
|
27713
27726
|
while(parent){parent.numEntities++;if(visible){parent.numVisibleEntities++;parent.checked=true;}parent=parent.parent;}}}}}}},{key:"_withNodeTree",value:function _withNodeTree(node,callback){callback(node);var children=node.children;if(!children){return;}for(var _i551=0,len=children.length;_i551<len;_i551++){this._withNodeTree(children[_i551],callback);}}},{key:"_createTrees",value:function _createTrees(){var _this161=this;if(this._rootNodes.length===0){return;}var rootNodeElements=this._rootNodes.map(function(rootNode){return _this161._createNodeElement(rootNode);});var rootNode=this._renderService.createRootNode();rootNodeElements.forEach(function(nodeElement){rootNode.appendChild(nodeElement);});this._containerElement.appendChild(rootNode);this._rootElement=rootNode;}},{key:"_createNodeElement",value:function _createNodeElement(node){var _this162=this;var contextmenuHandler=function contextmenuHandler(event){_this162.fire("contextmenu",{event:event,viewer:_this162._viewer,treeViewPlugin:_this162,treeViewNode:node});event.preventDefault();};var onclickHandler=function onclickHandler(event){_this162.fire("nodeTitleClicked",{event:event,viewer:_this162._viewer,treeViewPlugin:_this162,treeViewNode:node});event.preventDefault();};return this._renderService.createNodeElement(node,this._switchExpandHandler,this._checkboxChangeHandler,contextmenuHandler,onclickHandler);}},{key:"_expandSwitchElement",value:function _expandSwitchElement(switchElement){var _this163=this;var expanded=this._renderService.isExpanded(switchElement);if(expanded){return;}var nodeId=this._renderService.getId(switchElement);var nodeElements=this._nodeNodes[nodeId].children.map(function(node){return _this163._createNodeElement(node);});this._renderService.addChildren(switchElement,nodeElements);this._renderService.expand(switchElement,this._switchExpandHandler,this._switchCollapseHandler);}},{key:"_collapseNode",value:function _collapseNode(nodeId){var switchElement=this._renderService.getSwitchElement(nodeId);this._collapseSwitchElement(switchElement);}},{key:"_collapseSwitchElement",value:function _collapseSwitchElement(switchElement){this._renderService.collapse(switchElement,this._switchExpandHandler,this._switchCollapseHandler);}}]);return TreeViewPlugin;}(Plugin);/**
|
|
27714
27727
|
* For each Entity in its Scene, efficiently combines updates from multiple culling systems into a single "culled" state.
|
|
@@ -29663,7 +29676,7 @@ var headerBlockItems=[{item:'FileSignature',format:'char',size:4},{item:'FileSou
|
|
|
29663
29676
|
* @private
|
|
29664
29677
|
* @param arrayBuffer
|
|
29665
29678
|
* @returns {{}}
|
|
29666
|
-
*/var loadLASHeader=function loadLASHeader(arrayBuffer){var currentByte=0;var numOfVarLenRecords=0;var projectionStart=0;var dataView=new DataView(arrayBuffer);var buffer=new Uint8Array(6000);var getGeoKeys=function getGeoKeys(geoRecord){if(geoRecord===undefined){return undefined;}var projectionEnd=projectionStart+geoRecord["RecordLengthAfterHeader"];var geoTag=buffer.slice(projectionStart,projectionEnd);var arrayBuffer=bufferFlipper(geoTag);var dataView=new DataView(arrayBuffer);var byteCount=6;var numberOfKeys=Number(dataView.getUint16(byteCount,true));var geoKeys=[];while(numberOfKeys--){var keyTmp={};keyTmp.key=dataView.getUint16(byteCount+=2,true);keyTmp.tiffTagLocation=dataView.getUint16(byteCount+=2,true);keyTmp.count=dataView.getUint16(byteCount+=2,true);keyTmp.valueOffset=dataView.getUint16(byteCount+=2,true);geoKeys.push(keyTmp);}var projRecord=geoKeys.find(function(x){return x.key===3072;});if(projRecord&&projRecord.hasOwnProperty('valueOffset')){var epsg=projRecord.valueOffset;{return epsg;}}return undefined;};var getValue=function getValue(
|
|
29679
|
+
*/var loadLASHeader=function loadLASHeader(arrayBuffer){var currentByte=0;var numOfVarLenRecords=0;var projectionStart=0;var dataView=new DataView(arrayBuffer);var buffer=new Uint8Array(6000);var getGeoKeys=function getGeoKeys(geoRecord){if(geoRecord===undefined){return undefined;}var projectionEnd=projectionStart+geoRecord["RecordLengthAfterHeader"];var geoTag=buffer.slice(projectionStart,projectionEnd);var arrayBuffer=bufferFlipper(geoTag);var dataView=new DataView(arrayBuffer);var byteCount=6;var numberOfKeys=Number(dataView.getUint16(byteCount,true));var geoKeys=[];while(numberOfKeys--){var keyTmp={};keyTmp.key=dataView.getUint16(byteCount+=2,true);keyTmp.tiffTagLocation=dataView.getUint16(byteCount+=2,true);keyTmp.count=dataView.getUint16(byteCount+=2,true);keyTmp.valueOffset=dataView.getUint16(byteCount+=2,true);geoKeys.push(keyTmp);}var projRecord=geoKeys.find(function(x){return x.key===3072;});if(projRecord&&projRecord.hasOwnProperty('valueOffset')){var epsg=projRecord.valueOffset;{return epsg;}}return undefined;};var getValue=function getValue(_ref25){var item=_ref25.item,format=_ref25.format,size=_ref25.size;var str,array;switch(format){case'char':array=new Uint8Array(arrayBuffer,currentByte,size);currentByte+=size;str=uint8arrayToString(array);return[item,str];case'uShort':str=dataView.getUint16(currentByte,true);currentByte+=size;return[item,str];case'uLong':str=dataView.getUint32(currentByte,true);if(item==='NumberOfVariableLengthRecords'){numOfVarLenRecords=str;}currentByte+=size;return[item,str];case'uChar':str=dataView.getUint8(currentByte);currentByte+=size;return[item,str];case'double':str=dataView.getFloat64(currentByte,true);currentByte+=size;return[item,str];default:currentByte+=size;}};var getValues=function getValues(){var publicHeaderBlock={};headerBlockItems.forEach(function(obj){var myObj=getValue(_objectSpread({},obj));if(myObj!==undefined){if(myObj[0]==='FileSignature'&&myObj[1]!=='LASF'){throw new Error('Ivalid FileSignature. Is this a LAS/LAZ file');}publicHeaderBlock[myObj[0]]=myObj[1];}});var variableRecords=[];var variableLengthRecords=numOfVarLenRecords;var _loop7=function _loop7(){var variableObj={};variableLengthRecord.forEach(function(obj){var myObj=getValue(_objectSpread({},obj));variableObj[myObj[0]]=myObj[1];if(myObj[0]==='UserId'&&myObj[1]==='LASF_Projection'){projectionStart=currentByte-18+54;}});variableRecords.push(variableObj);};while(variableLengthRecords--){_loop7();}var geoRecord=variableRecords.find(function(x){return x.UserId==='LASF_Projection';});var epsg=getGeoKeys(geoRecord);if(epsg){publicHeaderBlock['epsg']=epsg;}return publicHeaderBlock;};return getValues();};var bufferFlipper=function bufferFlipper(buf){var ab=new ArrayBuffer(buf.length);var view=new Uint8Array(ab);for(var _i591=0;_i591<buf.length;++_i591){view[_i591]=buf[_i591];}return ab;};var uint8arrayToString=function uint8arrayToString(array){var str='';array.forEach(function(item){var c=String.fromCharCode(item);if(c!=="\0"){str+=c;}});return str.trim();};var MAX_VERTICES=500000;// TODO: Rough estimate
|
|
29667
29680
|
/**
|
|
29668
29681
|
* {@link Viewer} plugin that loads lidar point cloud geometry from LAS files.
|
|
29669
29682
|
*
|
|
@@ -30542,8 +30555,8 @@ var ctx={fileData:fileData,sceneModel:sceneModel,nextId:0,error:function error(e
|
|
|
30542
30555
|
* Destroys this DotBIMLoaderPlugin.
|
|
30543
30556
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(DotBIMLoaderPlugin.prototype),"destroy",this).call(this);}}]);return DotBIMLoaderPlugin;}(Plugin);var hex2rgb=function hex2rgb(color){var rgb=function rgb(idx){return parseInt(color.substr(idx+1,2),16)/255;};return[rgb(0),rgb(2),rgb(4)];};var triangulateEarClipping=function triangulateEarClipping(planeCoords){var polygonVertices=[];for(var _i612=0;_i612<planeCoords.length;++_i612){polygonVertices.push(_i612);}var isCCW=function(){var ba=math.vec2();var bc=math.vec2();var anglesSum=0;for(var _i613=0;_i613<polygonVertices.length;++_i613){var _a9=planeCoords[polygonVertices[_i613]];var b=planeCoords[polygonVertices[(_i613+1)%polygonVertices.length]];var c=planeCoords[polygonVertices[(_i613+2)%polygonVertices.length]];math.subVec2(_a9,b,ba);math.subVec2(c,b,bc);var theta=math.dotVec2(ba,bc)/Math.sqrt(math.sqLenVec2(ba)*math.sqLenVec2(bc));var _angle2=Math.acos(Math.max(-1,Math.min(theta,1)));var convex=ba[0]*bc[1]-ba[1]*bc[0]>=0;anglesSum+=convex?_angle2:2*Math.PI-_angle2;}return anglesSum<polygonVertices.length*Math.PI;}();var pointInTriangle=function(){var sign=function sign(p1,p2,p3){return(p1[0]-p3[0])*(p2[1]-p3[1])-(p2[0]-p3[0])*(p1[1]-p3[1]);};return function(pt,v1,v2,v3){var d1=sign(pt,v1,v2);var d2=sign(pt,v2,v3);var d3=sign(pt,v3,v1);var has_neg=d1<0||d2<0||d3<0;var has_pos=d1>0||d2>0||d3>0;return!(has_neg&&has_pos);};}();var baseTriangles=[];var vertices=(isCCW?polygonVertices:polygonVertices.slice(0).reverse()).map(function(i){return{idx:i};});vertices.forEach(function(v,i){v.prev=vertices[(i-1+vertices.length)%vertices.length];v.next=vertices[(i+1)%vertices.length];});var ba=math.vec2();var bc=math.vec2();while(vertices.length>2){var earIdx=0;var _loop9=function _loop9(){if(earIdx>=vertices.length){throw"isCCW = ".concat(isCCW,"; earIdx = ").concat(earIdx,"; len = ").concat(vertices.length);}var v=vertices[earIdx];var a=planeCoords[v.prev.idx];var b=planeCoords[v.idx];var c=planeCoords[v.next.idx];math.subVec2(a,b,ba);math.subVec2(c,b,bc);if(ba[0]*bc[1]-ba[1]*bc[0]>=0// a convex vertex
|
|
30544
30557
|
&&vertices.every(// no other vertices inside
|
|
30545
|
-
function(vv){return vv===v||vv===v.prev||vv===v.next||!pointInTriangle(planeCoords[vv.idx],a,b,c);}))return"break";++earIdx;};while(true){var _ret3=_loop9();if(_ret3==="break")break;}var ear=vertices[earIdx];vertices.splice(earIdx,1);baseTriangles.push([ear.idx,ear.next.idx,ear.prev.idx]);var prev=ear.prev;prev.next=ear.next;var next=ear.next;next.prev=ear.prev;}return[planeCoords,baseTriangles,isCCW];};var marker3D=function marker3D(scene,color){var marker=new Dot3D(scene,{},scene.canvas.canvas.parentNode,{borderColor:"white",fillColor:color,zIndex:100});return{update:function update(worldPos){if(worldPos){marker.worldPos=worldPos;}marker.setVisible(!!worldPos);},setHighlighted:function setHighlighted(h){return marker.setHighlighted(h);},getCanvasPos:function getCanvasPos(){return marker.canvasPos;},getWorldPos:function getWorldPos(){return marker.worldPos;},destroy:function destroy(){return marker.destroy();}};};var wire3D=function wire3D(scene,color,startWorldPos){var wire=new Wire3D(scene,scene.canvas.canvas.ownerDocument.body,{color:color,thickness:1,thicknessClickable:6});wire.setVisible(false);return{update:function update(endWorldPos){if(endWorldPos){wire.setEnds(startWorldPos,endWorldPos);}wire.setVisible(!!endWorldPos);},destroy:function destroy(){return wire.destroy();}};};var basePolygon3D=function basePolygon3D(scene,color,alpha){var mesh=null;var updateBase=function updateBase(points){if(points){if(mesh){mesh.destroy();}try{var
|
|
30546
|
-
var ind=(
|
|
30558
|
+
function(vv){return vv===v||vv===v.prev||vv===v.next||!pointInTriangle(planeCoords[vv.idx],a,b,c);}))return"break";++earIdx;};while(true){var _ret3=_loop9();if(_ret3==="break")break;}var ear=vertices[earIdx];vertices.splice(earIdx,1);baseTriangles.push([ear.idx,ear.next.idx,ear.prev.idx]);var prev=ear.prev;prev.next=ear.next;var next=ear.next;next.prev=ear.prev;}return[planeCoords,baseTriangles,isCCW];};var marker3D=function marker3D(scene,color){var marker=new Dot3D(scene,{},scene.canvas.canvas.parentNode,{borderColor:"white",fillColor:color,zIndex:100});return{update:function update(worldPos){if(worldPos){marker.worldPos=worldPos;}marker.setVisible(!!worldPos);},setHighlighted:function setHighlighted(h){return marker.setHighlighted(h);},getCanvasPos:function getCanvasPos(){return marker.canvasPos;},getWorldPos:function getWorldPos(){return marker.worldPos;},destroy:function destroy(){return marker.destroy();}};};var wire3D=function wire3D(scene,color,startWorldPos){var wire=new Wire3D(scene,scene.canvas.canvas.ownerDocument.body,{color:color,thickness:1,thicknessClickable:6});wire.setVisible(false);return{update:function update(endWorldPos){if(endWorldPos){wire.setEnds(startWorldPos,endWorldPos);}wire.setVisible(!!endWorldPos);},destroy:function destroy(){return wire.destroy();}};};var basePolygon3D=function basePolygon3D(scene,color,alpha){var mesh=null;var updateBase=function updateBase(points){if(points){if(mesh){mesh.destroy();}try{var _ref26,_ref27;var _triangulateEarClippi=triangulateEarClipping(points.map(function(p){return[p[0],p[2]];})),_triangulateEarClippi2=_slicedToArray(_triangulateEarClippi,2),baseVertices=_triangulateEarClippi2[0],baseTriangles=_triangulateEarClippi2[1];var positions=(_ref26=[]).concat.apply(_ref26,_toConsumableArray(baseVertices.map(function(p){return[p[0],points[0][1],p[1]];})));// To convert from Float64Array into an Array
|
|
30559
|
+
var ind=(_ref27=[]).concat.apply(_ref27,_toConsumableArray(baseTriangles));mesh=new Mesh(scene,{pickable:false,// otherwise there's a WebGL error inside PickMeshRenderer.prototype.drawMesh
|
|
30547
30560
|
geometry:new ReadableGeometry(scene,{positions:positions,indices:ind,normals:math.buildNormals(positions,ind)}),material:new PhongMaterial(scene,{alpha:alpha!==undefined?alpha:0.5,backfaces:true,diffuse:hex2rgb(color)})});}catch(e){mesh=null;}}if(mesh){mesh.visible=!!points;}};updateBase(null);return{updateBase:updateBase,destroy:function destroy(){return mesh&&mesh.destroy();}};};var startAARectCreateUI=function startAARectCreateUI(scene,markersColor,pointerLens,select3dPoint,withPoints,onPointsSelected){var marker1=marker3D(scene,markersColor);var marker2=marker3D(scene,markersColor);var updatePointerLens=pointerLens?function(canvasPos){pointerLens.visible=!!canvasPos;if(canvasPos){pointerLens.canvasPos=canvasPos;}}:function(){};var deactivatePointSelection=select3dPoint(function(){updatePointerLens(null);marker1.update(null);},function(canvasPos,worldPos){updatePointerLens(canvasPos);marker1.update(worldPos);},function(point1CanvasPos,point1WorldPos){marker1.update(point1WorldPos);deactivatePointSelection=select3dPoint(function(){updatePointerLens(null);marker2.update(null);withPoints(null);},function(canvasPos,point2WorldPos){updatePointerLens(canvasPos);marker2.update(point2WorldPos);withPoints(math.distVec3(point1WorldPos,point2WorldPos)>0.01&&[point1WorldPos,point2WorldPos]);},function(point2CanvasPos,point2WorldPos){// `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
|
|
30548
30561
|
// This works around an unidentified bug somewhere around OcclusionLayer, that causes error
|
|
30549
30562
|
// [.WebGL-0x13400c47e00] GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call
|
|
@@ -30556,11 +30569,11 @@ marker2.update(point2WorldPos);marker1.destroy();marker2.destroy();updatePointer
|
|
|
30556
30569
|
*/function Zone(plugin){var _this184;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Zone);_this184=_super174.call(this,plugin.viewer.scene,cfg);/**
|
|
30557
30570
|
* The {@link ZonesPlugin} that owns this Zone.
|
|
30558
30571
|
* @type {ZonesPlugin}
|
|
30559
|
-
*/_this184.plugin=plugin;_this184._container=cfg.container;if(!_this184._container){throw"config missing: container";}_this184._eventSubs={};_this184.plugin.viewer.scene;_this184._geometry=cfg.geometry;cfg.onMouseOver?function(event){cfg.onMouseOver(event,_assertThisInitialized(_this184));_this184.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseover',event));}:null;cfg.onMouseLeave?function(event){cfg.onMouseLeave(event,_assertThisInitialized(_this184));_this184.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseleave',event));}:null;cfg.onContextMenu?function(event){cfg.onContextMenu(event,_assertThisInitialized(_this184));}:null;_this184._alpha="alpha"in cfg&&cfg.alpha!==undefined?cfg.alpha:0.5;_this184.color=cfg.color;_this184._visible=true;_this184._rebuildMesh();return _this184;}_createClass(Zone,[{key:"_rebuildMesh",value:function _rebuildMesh(){var
|
|
30572
|
+
*/_this184.plugin=plugin;_this184._container=cfg.container;if(!_this184._container){throw"config missing: container";}_this184._eventSubs={};_this184.plugin.viewer.scene;_this184._geometry=cfg.geometry;cfg.onMouseOver?function(event){cfg.onMouseOver(event,_assertThisInitialized(_this184));_this184.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseover',event));}:null;cfg.onMouseLeave?function(event){cfg.onMouseLeave(event,_assertThisInitialized(_this184));_this184.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseleave',event));}:null;cfg.onContextMenu?function(event){cfg.onContextMenu(event,_assertThisInitialized(_this184));}:null;_this184._alpha="alpha"in cfg&&cfg.alpha!==undefined?cfg.alpha:0.5;_this184.color=cfg.color;_this184._visible=true;_this184._rebuildMesh();return _this184;}_createClass(Zone,[{key:"_rebuildMesh",value:function _rebuildMesh(){var _ref28,_this185=this;var scene=this.plugin.viewer.scene;var planeCoords=this._geometry.planeCoordinates.slice();var downward=this._geometry.height<0;var altitude=this._geometry.altitude+(downward?this._geometry.height:0);var height=this._geometry.height*(downward?-1:1);var _triangulateEarClippi3=triangulateEarClipping(planeCoords),_triangulateEarClippi4=_slicedToArray(_triangulateEarClippi3,3),baseVertices=_triangulateEarClippi4[0],baseTriangles=_triangulateEarClippi4[1],isCCW=_triangulateEarClippi4[2];// TODO: prevent crossing edges
|
|
30560
30573
|
var pos=[];var ind=[];var addPlane=function addPlane(isCeiling){var baseIdx=pos.length;var _iterator42=_createForOfIteratorHelper(baseVertices),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var c=_step42.value;pos.push([c[0],altitude+(isCeiling?height:0),c[1]]);}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}var _iterator43=_createForOfIteratorHelper(baseTriangles),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var t=_step43.value;ind.push.apply(ind,_toConsumableArray((isCeiling?t:t.slice(0).reverse()).map(function(i){return i+baseIdx;})));}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}};addPlane(false);// floor
|
|
30561
30574
|
addPlane(true);// ceiling
|
|
30562
30575
|
// sides
|
|
30563
|
-
var _loop10=function _loop10(_i614){var a=baseVertices[_i614];var b=baseVertices[(baseVertices.length+_i614+(isCCW?1:-1))%baseVertices.length];var f=altitude;var c=altitude+height;var baseIdx=pos.length;pos.push([a[0],f,a[1]],[b[0],f,b[1]],[b[0],c,b[1]],[a[0],c,a[1]]);ind.push.apply(ind,_toConsumableArray([0,1,2,0,2,3].map(function(i){return i+baseIdx;})));};for(var _i614=0;_i614<baseVertices.length;++_i614){_loop10(_i614);}if(this._zoneMesh){this._zoneMesh.destroy();}var min=function min(idx){return Math.min.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var max=function max(idx){return Math.max.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var xmin=min(0);var ymin=min(1);var zmin=min(2);var xmax=max(0);var ymax=max(1);var zmax=max(2);this._center=math.vec3([(xmin+xmax)/2,(ymin+ymax)/2,(zmin+zmax)/2]);var positions=(
|
|
30576
|
+
var _loop10=function _loop10(_i614){var a=baseVertices[_i614];var b=baseVertices[(baseVertices.length+_i614+(isCCW?1:-1))%baseVertices.length];var f=altitude;var c=altitude+height;var baseIdx=pos.length;pos.push([a[0],f,a[1]],[b[0],f,b[1]],[b[0],c,b[1]],[a[0],c,a[1]]);ind.push.apply(ind,_toConsumableArray([0,1,2,0,2,3].map(function(i){return i+baseIdx;})));};for(var _i614=0;_i614<baseVertices.length;++_i614){_loop10(_i614);}if(this._zoneMesh){this._zoneMesh.destroy();}var min=function min(idx){return Math.min.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var max=function max(idx){return Math.max.apply(Math,_toConsumableArray(pos.map(function(p){return p[idx];})));};var xmin=min(0);var ymin=min(1);var zmin=min(2);var xmax=max(0);var ymax=max(1);var zmax=max(2);this._center=math.vec3([(xmin+xmax)/2,(ymin+ymax)/2,(zmin+zmax)/2]);var positions=(_ref28=[]).concat.apply(_ref28,_toConsumableArray(pos.map(function(p){return math.subVec3(p,_this185._center,p);})));this._zoneMesh=new Mesh(scene,{origin:this._center,edges:this._edges,geometry:new ReadableGeometry(scene,{positions:positions,indices:ind,normals:math.buildNormals(positions,ind)}),material:new PhongMaterial(scene,{alpha:this._alpha,backfaces:true,diffuse:hex2rgb(this._color)}),visible:this._visible});this._zoneMesh.highlighted=this._highlighted;this._zoneMesh.zone=this;{var _u2=math.vec2();var v=math.vec2();var baseArea=0;var _iterator44=_createForOfIteratorHelper(baseTriangles),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var t=_step44.value;var p0=baseVertices[t[0]];var p1=baseVertices[t[1]];var p2=baseVertices[t[2]];math.subVec2(p1,p0,_u2);math.subVec2(p2,p0,v);baseArea+=Math.abs(_u2[0]*v[1]-_u2[1]*v[0]);}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}this._baseArea=baseArea/2;}this._metrics=null;}},{key:"baseArea",get:function get(){return this._baseArea;}},{key:"area",get:function get(){return this._getMetrics().area;}},{key:"volume",get:function get(){return this._getMetrics().volume;}},{key:"_getMetrics",value:function _getMetrics(){if(this._metrics===null){// Sum the volume of tetrahedrons formed by the origin and face triangles
|
|
30564
30577
|
var volume=0;var _area4=0;var geo=this._zoneMesh.geometry;var pts=[math.vec3(),math.vec3(),math.vec3()];var tmpVec3=math.vec3();for(var _i615=0;_i615<geo.indices.length;_i615+=3){for(var off=0;off<3;++off){var _p4=pts[off];var pIdx=3*geo.indices[_i615+off];for(var c=0;c<3;++c){_p4[c]=geo.positions[pIdx+c];}}volume+=math.dotVec3(pts[0],math.cross3Vec3(pts[1],pts[2],tmpVec3));math.subVec3(pts[1],pts[0],pts[1]);math.subVec3(pts[2],pts[0],pts[2]);_area4+=math.lenVec3(math.cross3Vec3(pts[1],pts[2],tmpVec3));}this._metrics={area:_area4/2,volume:volume/6};}return this._metrics;}},{key:"sectionedAverage",value:function sectionedAverage(sectionPlanes){var planeCoords=this._geometry.planeCoordinates.slice();var faces=[];{var h=this._geometry.height;var _a10=this._geometry.altitude;var c=_a10+Math.max(0,h);var _f2=_a10+Math.min(0,h);var addPlane=function addPlane(isCeiling){var face=planeCoords.map(function(p){return[p[0],isCeiling?c:_f2,p[1]];});faces.push(isCeiling?face:face.slice(0).reverse());};addPlane(true);// ceiling
|
|
30565
30578
|
addPlane(false);// floor
|
|
30566
30579
|
// sides
|