Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

troika-3d

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-3d - npm Package Compare versions

Comparing version 0.34.0 to 0.34.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [0.34.2](https://github.com/protectwise/troika/compare/v0.34.1...v0.34.2) (2020-11-09)
### Bug Fixes
* **troika-3d:** prevent tree getting in bad state due to removal of orphanable children ([8121425](https://github.com/protectwise/troika/commit/81214255cba846c4e832ac3ada3225e1688c59bd))
# [0.34.0](https://github.com/protectwise/troika/compare/v0.33.1...v0.34.0) (2020-10-19)

@@ -8,0 +19,0 @@

148

dist/troika-3d.umd.min.js

@@ -12,75 +12,75 @@ 'use strict';(function(f,e){"object"===typeof exports&&"undefined"!==typeof module?e(exports,require("three"),require("troika-core"),require("troika-three-utils"),require("react"),require("prop-types")):"function"===typeof define&&define.amd?define("exports three troika-core troika-three-utils react prop-types".split(" "),e):(f="undefined"!==typeof globalThis?globalThis:f||self,e(f.troika_3d={},f.THREE,f.troika_core,f.troika_three_utils,f.React,f.PropTypes))})(this,function(f,e,k,x,n,A){function R(c){return c&&

Ga=new e.Vector3,t=function(){var c={callback:function(b){c.value=b},value:null};return c}(),Ha={type:"removed"},D=[],Ia=0,Ja=0,m=function(c){function b(a,d){c.call(this,a);d.matrixAutoUpdate=!1;this.threeObject=d;d.$facade=this;var b=!1!==d.isRenderable;b||(d.layers.mask=0);for(;a;){if(a.isObject3DFacade){this._parentObject3DFacade=a;b&&this._addToThreeObjectTree();break}a=a.parent}this.notifyWorld("object3DAdded")}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=
b;b.prototype.afterUpdate=function(){this.updateMatrices();this._checkBoundsChange();this._worldMatrixVersion>this._worldMatrixVersionAfterLastUpdate&&(this.shouldUpdateChildren()||this.traverse(function(a,d){a!==d&&a.updateMatrices&&(a.updateMatrices(),a._checkBoundsChange())},this),this._worldMatrixVersionAfterLastUpdate=this._worldMatrixVersion);c.prototype.afterUpdate.call(this);if(this._removeChildIds){var a=this.threeObject,d=this._removeChildIds;a.children=a.children.filter(function(a){return a.id in
d?(a.parent=null,a.dispatchEvent(Ha),!1):!0});var b=this._parentObject3DFacade;S(a)&&b&&b.threeObject===a.parent&&b._queueRemoveChildObject3D(a.id);this._removeChildIds=null}};b.prototype.updateMatrices=function(){var a=this.threeObject,d=this._parentObject3DFacade;if(this._matrixChanged){a.matrix.compose(a.position,a.quaternion,a.scale);this._matrixChanged=!1;var b=!0}else b=d&&d._worldMatrixVersion>this._worldMatrixVersion;if(b){d?a.matrixWorld.multiplyMatrices(d.threeObject.matrixWorld,a.matrix):
a.matrixWorld.copy(a.matrix);a=a.children;d=0;for(b=a.length;d<b;d++)a[d].$facade||a[d].updateMatrixWorld(!0);this.markWorldMatrixDirty()}};b.prototype.markWorldMatrixDirty=function(){this._worldMatrixVersion=++Ia;this._boundsChanged=!0};b.prototype._checkBoundsChange=function(){var a=this._boundsChanged;if(!a){var d=this._getGeometryBoundingSphere();d&&d.version!==this._lastGeometrySphereVersion&&(a=!0,this._lastGeometrySphereVersion=d.version)}a&&(this.notifyWorld("object3DBoundsChanged"),this._boundsChanged=
!1)};b.prototype.getWorldPosition=function(a){this.updateMatrices();return(a||new e.Vector3).setFromMatrixPosition(this.threeObject.matrixWorld)};b.prototype.getCameraPosition=function(a){a=a||new e.Vector3;this.notifyWorld("getCameraPosition",a);return a};b.prototype.getCameraFacade=function(){t.value=null;this.notifyWorld("getCameraFacade",t);return t.value};b.prototype.getCameraDistance=function(){var a=this.getCameraPosition(Ga),d=this.getWorldPosition(ja);return a.distanceTo(d)};b.prototype.getProjectedPosition=
function(a,d,b){this.updateMatrices();t.value=null;t.worldPosition=ja.set(a||0,d||0,b||0).applyMatrix4(this.threeObject.matrixWorld);this.notifyWorld("projectWorldPosition",t);return t.value};b.prototype.getSceneFacade=function(){t.value=null;this.notifyWorld("getSceneFacade",t);return t.value};b.prototype.getBoundingSphere=function(){var a=this._getGeometryBoundingSphere();if(!a)return null;this.updateMatrices();var d=this._boundingSphere;d||(d=this._boundingSphere=new e.Sphere);if(d._geometrySphereVersion!==
a.version||d._worldMatrixVersion!==this._worldMatrixVersion)d.copy(a),d.applyMatrix4(this.threeObject.matrixWorld),d._worldMatrixVersion=this._worldMatrixVersion,d._geometrySphereVersion=a.version;return d};b.prototype._getGeometryBoundingSphere=function(){var a=this.getGeometry();if(a){var d=a.boundingSphere,b=!1;if(d)if(a.isBufferGeometry){var c=a.attributes.position;c&&d._posAttrVersion!==c.version&&(a.computeBoundingSphere(),d._posAttrVersion=c.version,b=!0)}else a._lastBoundingSphere&&d.equals(a._lastBoundingSphere)||
(a._lastBoundingSphere=d.clone(),b=!0);else a.computeBoundingSphere(),d=a.boundingSphere,b=!0;b&&(d.version=++Ja);return d}return null};b.prototype.getGeometry=function(){var a=this.threeObject;return a&&a.geometry};b.prototype.raycast=function(a){return this.threeObject?this._raycastObject(this.threeObject,a):null};b.prototype._raycastObject=function(a,d){if(a.visible){D.length=0;var b=null,c=this.raycastSide;null!=c&&(b=a.material.side,a.material.side=c);a.raycast(d,D);null!==b&&(a.material.side=
b);if(D.length)return D.sort(ya),D.slice()}return null};b.prototype._addToThreeObjectTree=function(){var a=this._parentObject3DFacade;a&&this.threeObject.parent!==a.threeObject&&(a.threeObject.add(this.threeObject),a._addToThreeObjectTree())};b.prototype._queueRemoveChildObject3D=function(a){(this._removeChildIds||(this._removeChildIds=Object.create(null)))[a]=!0};b.prototype.destructor=function(){this.notifyWorld("object3DRemoved");var a=this._parentObject3DFacade;a&&a._queueRemoveChildObject3D(this.threeObject.id);
delete this.threeObject;c.prototype.destructor.call(this)};return b}(k.PointerEventTarget);["castShadow","receiveShadow","renderOrder","visible"].forEach(function(c){Object.defineProperty(m.prototype,c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});m.prototype.raycastSide=null;ia({position:{x:"x",y:"y",z:"z"},scale:{x:"scaleX",y:"scaleY",z:"scaleZ"},rotation:{x:"rotateX",y:"rotateY",z:"rotateZ",order:"rotateOrder"},quaternion:{x:"quaternionX",y:"quaternionY",
z:"quaternionZ",w:"quaternionW"}},function(c,b){ia(c,function(a,d){Object.defineProperty(m.prototype,a,{get:(new Function("return function "+a+"$get() {\n return this.threeObject."+b+"."+d+"\n}"))(),set:(new Function("return function "+a+"$set(value) {\n //let obj = this.threeObject."+b+"\n if (this.threeObject."+b+"."+d+" !== value) {\n this.threeObject."+b+"."+d+" = value\n if (!this._matrixChanged) {\n this._matrixChanged = true\n }\n }\n}"))()})})});Object.defineProperty(m.prototype,
"scale",{get:function(){return this.threeObject.scale.x},set:function(c){var b=this.threeObject.scale;if(c!==b.x||c!==b.y||c!==b.z)b.x=b.y=b.z=c,this._matrixChanged||(this._matrixChanged=!0)}});Object.defineProperty(m.prototype,"isObject3DFacade",{value:!0});A(m.prototype,{threeObject:null,_parentObject3DFacade:null,_removeChildIds:null,_matrixChanged:!0,_worldMatrixVersion:-1,_worldMatrixVersionAfterLastUpdate:-1,_boundingSphereChanged:!1});k.Facade.defineEventProperty(m,"onBeforeRender","beforerender");
k.Facade.defineEventProperty(m,"onAfterRender","afterrender");var za=function(){},X=new e.Raycaster,Ba=new e.Vector2,U=new e.Vector3,W=new e.Matrix4,B=new e.Quaternion,V=new e.Vector3(0,1,0),Aa=0,ka=T(e.PerspectiveCamera,["fov","aspect","near","far"],["focus","filmGauge","filmOffset"]);A=T(e.OrthographicCamera,"left right top bottom near far".split(" "));var la=function(c){function b(a){var d=new e.Group;d.isRenderable=!1;c.call(this,a,d)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);
return b.prototype.constructor=b}(m),Ka=function(c){function b(a){var d=new e.Object3D;d.isRenderable=!1;c.call(this,a,d);this.html=null;this.exact=!1;this.notifyWorld("addHtmlOverlay",this)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.destructor=function(){this.notifyWorld("removeHtmlOverlay",this);c.prototype.destructor.call(this)};return b}(m),Y=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&
c.prototype);b.prototype.constructor=b;var a={color:{configurable:!0},shadow:{configurable:!0}};a.color.set=function(a){this.threeObject.color.set(a)};a.color.get=function(){return this.threeObject.color.getHex()};a.shadow.get=function(){return this.threeObject.shadow};a.shadow.set=function(a){k.utils.assignDeep(this.threeObject.shadow,a)};Object.defineProperties(b.prototype,a);return b}(m);"intensity distance angle penumbra decay castShadow width height".split(" ").forEach(function(c){Object.defineProperty(Y.prototype,
c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});var ma=y(e.AmbientLight),na=y(e.DirectionalLight,e.DirectionalLightHelper),oa=y(e.SpotLight,e.SpotLightHelper),pa=y(e.PointLight,e.PointLightHelper),qa=y(e.HemisphereLight,e.HemisphereLightHelper,{groundColor:{set:function(c){this.threeObject.groundColor.set(c)},get:function(){return this.threeObject.groundColor.getHex()}}}),La=y(e.RectAreaLight),Ea="\ntroika_modelMatrix = mat4(\n %0.x, %1.x, %2.x, 0.0,\n %0.y, %1.y, %2.y, 0.0,\n %0.z, %1.z, %2.z, 0.0,\n %0.w, %1.w, %2.w, 1.0\n);\n".replace(/%/g,
"troika_modelMatrixRow"),aa=/\bmodelMatrix\b/g,ba=/\bmodelViewMatrix\b/g,ca=/\bnormalMatrix\b/g,ra=/\buniform\s+(int|float|vec[234])\s+$/,F=function(c,b,a){return ra.test(a.substr(0,b))?c:"troika_"+c},Fa=function(c,b,a){return ra.test(a.substr(0,b))?c:"troika_vary_"+c},Z=new WeakMap,L=k.utils.assign,M=function(c){function b(a){c.call(this,a);this._instanceables=Object.create(null);this._batchGeometryPool=new G;this._needsRebatch=!0;this.addEventListener("beforerender",this._setupBatchObjects.bind(this));
this.addEventListener("afterrender",this._teardownBatchObjects.bind(this))}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.onNotifyWorld=function(a,d,b){var c=this._notifyWorldHandlers[d];if(c)c.call(this,a,b);else if(this.parent)this.parent.onNotifyWorld(a,d,b)};b.prototype._setupBatchObjects=function(a,d,b){b=this._instanceables;a=this._batchObjectsByKey;var c=this._needsRebatch;if(!c)for(var g in a)if(this._getBatchKey(a[g][0].$troikaBatchBaseObj)!==
g){c=!0;break}if(c){a=this._batchObjectsByKey=Object.create(null);g=this._batchGeometryPool;for(var e in b){c=b[e];var h=c.threeObject,f=c.instancedThreeObject;if(f&&h.visible){var k=this._getBatchKey(f),z=f.material.instanceUniforms,m=a[k]||(a[k]=[]),n=(k=m[m.length-1])&&k.geometry;if(!n||128===K(n)){k=this._getBatchObject(f);n=k.geometry;for(var q=n._instanceAttrs.matrix,p=0;3>p;p++)q[p].version++;if(z)for(q=n._instanceAttrs.uniforms,p=z.length;p--;)q[z[p]].version++;m.push(k)}m=K(n);fa(n,m+1);
q=n._instanceAttrs.matrix;h=h.matrixWorld.elements;q[0].setXYZW(m,h[0],h[4],h[8],h[12]);q[1].setXYZW(m,h[1],h[5],h[9],h[13]);q[2].setXYZW(m,h[2],h[6],h[10],h[14]);if(z)for(q=n._instanceAttrs.uniforms,h=z.length;h--;){p=z[h];n=q[p];var r=c._instanceUniforms;p=r&&p in r?r[p]:ea(f.material,p);da(n,m,p)}c._instancingBatchObject=k;c._instancingBatchAttrOffset=m}else c._instancingBatchObject=c._instancingBatchAttrOffset=null}g.disposeUnused()}g=b=e=0;for(var t in a)for(c=a[t],d.children.push.apply(d.children,
c),b++,f=c.length;f--;)e++,g+=K(c[f].geometry);this.notifyWorld("statsUpdate",{"Instancing Batch Groups":b,"Instancing Batches":e,"Instanced Objects":g});this._needsRebatch=!1};b.prototype._onInstanceAdded=function(a){this._instanceables[a.$facadeId]=a;this._needsRebatch=!0};b.prototype._onInstanceRemoved=function(a){delete this._instanceables[a.$facadeId];this._needsRebatch=!0};b.prototype._onInstanceChanged=function(a){this._needsRebatch=!0};b.prototype._onInstanceMatrixChanged=function(a){if(!this._needsRebatch){var d=
a.instancedThreeObject,b=a._instancingBatchObject,c=a._instancingBatchAttrOffset;d&&b&&this._getBatchKey(d)===this._getBatchKey(b)?(d=b.geometry._instanceAttrs.matrix,a=a.threeObject.matrixWorld.elements,d[0].setXYZW(c,a[0],a[4],a[8],a[12]).version++,d[1].setXYZW(c,a[1],a[5],a[9],a[13]).version++,d[2].setXYZW(c,a[2],a[6],a[10],a[14]).version++):(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._onInstanceUniformChanged=function(a,b){if(!this._needsRebatch){var d=
a.instancedThreeObject,c=a._instancingBatchObject;d&&c&&this._getBatchKey(d)===this._getBatchKey(c)?(d=c.geometry._instanceAttrs.uniforms[b],da(d,a._instancingBatchAttrOffset,a._instanceUniforms[b]),d.version++):(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._getBatchKey=function(a){var b=this._batchKeysCache||(this._batchKeysCache=Object.create(null)),c=b&&b[a.id];if(!c){c=a.material;var l=c.instanceUniforms;c=a.geometry.id+"|"+c.id+"|"+(l?l.sort().join(","):
"");b[a.id]=c}return c};b.prototype._getInstanceUniformSizes=function(a){var b=this._uniformSizesCache||(this._uniformSizesCache=new Map),c=b.get(a);c||(c=Object.create(null),a.instanceUniforms&&a.instanceUniforms.forEach(function(b){var d=ea(a,b);d=null==d?0:"number"===typeof d?1:d.isVector2?2:d.isVector3||d.isColor?3:d.isVector4?4:Array.isArray(d)?d.length:0;0<d?c[b]=d:console.warn("Could not determine item size for uniform "+b)}),b.set(a,c));return c};b.prototype._getBatchObject=function(a){var b=
a.geometry,c=a.material;if(!b.isBufferGeometry)throw Error("Instanceable proto object must use a BufferGeometry");var l=this._getBatchKey(a),u=this._getInstanceUniformSizes(c);b=this._batchGeometryPool.borrow(l,b,u);fa(b,0);var J=Ca(c),h,f;c=Object.create(a,{geometry:{value:b},material:{value:J},visible:{value:!0},frustumCulled:{value:!1},customDepthMaterial:{get:function(){h||(h=J.getDepthMaterial(),h.isShaderMaterial=!0);return h}},customDistanceMaterial:{get:function(){f||(f=J.getDistanceMaterial(),
f.isShaderMaterial=!0,f.uniforms=L({viewMatrix:{value:new e.Matrix4}},f.uniforms));return f}},modelViewMatrix:{value:function(){var a=new e.Matrix4;a.multiplyMatrices=function(a,b){f&&(f.uniforms.viewMatrix.value.copy(a),f.uniformsNeedUpdate=!0);return e.Matrix4.prototype.multiplyMatrices.call(this,a,b)};return a}()}});c.$troikaBatchBaseObj=a;c.$troikaInstancingManager=this;return c};b.prototype._teardownBatchObjects=function(a,b,c){var d=this;this._batchGeometryPool.releaseAll();this._uniformSizesCache=
this._batchKeysCache=null;b.children=b.children.filter(function(a){return a.$troikaInstancingManager!==d})};b.prototype.destructor=function(){var a=this._batchGeometryPool;a.releaseAll();a.disposeUnused();c.prototype.destructor.call(this)};return b}(la),G=function(){this._poolsByKey=Object.create(null)};G.prototype.borrow=function(c,b,a){var d=this._poolsByKey;c=d[c]||(d[c]={geometries:[],firstFree:0});d=c.geometries[c.firstFree++];if(!d){d=new e.InstancedBufferGeometry;L(d,b);d.attributes=L({},b.attributes);
b=d._instanceAttrs={matrix:[],uniforms:Object.create(null)};for(var g=0;3>g;g++){var l=new e.InstancedBufferAttribute(new Float32Array(512),4);l.setUsage?l.setUsage(35048):l.dynamic=!0;d.attributes["troika_modelMatrixRow"+g]=l;b.matrix[g]=l}for(var u in a)g=a[u],g=new e.InstancedBufferAttribute(new Float32Array(128*g),g),g.setUsage?g.setUsage(35048):g.dynamic=!0,d.attributes["troika_"+u]=g,b.uniforms[u]=g;c.geometries.push(d)}return d};G.prototype.releaseAll=function(){var c=this._poolsByKey;if(c)for(var b in c)c[b].firstFree=
0};G.prototype.disposeUnused=function(){var c=this._poolsByKey;if(c)for(var b in c){var a=c[b],d=a.firstFree;a=a.geometries;for(var g=d,l=a.length;g<l;g++){var e=a[g].attributes,f;for(f in e)e.hasOwnProperty(f)&&0!==f.indexOf("troika_")&&delete e[f];try{a[g].dispose()}catch(h){}a[g]._instanceAttrs=null}a.length=d}};var r=M.prototype;r._notifyWorldHandlers={instanceableAdded:r._onInstanceAdded,instanceableRemoved:r._onInstanceRemoved,instanceableChanged:r._onInstanceChanged,instanceableMatrixChanged:r._onInstanceMatrixChanged,
instanceableUniformChanged:r._onInstanceUniformChanged};var Ma={ambient:ma,directional:na,spot:oa,point:pa,hemisphere:qa},Na=[{distance:Infinity}],Oa=new e.Sphere(void 0,Infinity),sa=[null],ta=function(c){function b(a){var b=new e.Scene;b.autoUpdate=!1;c.call(this,a,b)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={fog:{configurable:!0}};b.prototype.afterUpdate=function(){var a=this.threeObject;a.background=this.background||null;a.environment=this.environment||
null;c.prototype.afterUpdate.call(this)};b.prototype.describeChildren=function(){var a={key:"instancingMgr",facade:M,children:this.objects},b=this.lights;b&&(a=[a],Array.isArray(b)||(sa[0]=b,b=sa),b.forEach(function(b,d){var c=b.facade||Ma[b.type];if("function"===typeof c){var g=k.utils.assign({},b);delete g.type;g.key=b.key||"light"+d;g.facade=c;a.push(g)}}));return a};a.fog.set=function(a){var b=this._fogObj;if(a){var c="density"in a,d=c?e.FogExp2:e.Fog;b&&b instanceof d||(b=this._fogObj=new d);
b.color.set(a.color);c?b.density=a.density:(b.near=a.near,b.far=a.far)}else b=this._fogObj=null;this.threeObject.fog=b};b.prototype.getBoundingSphere=function(){return Oa};b.prototype.raycast=function(a){return Na};Object.defineProperties(b.prototype,a);return b}(m);r=k.utils.assign;var Pa=k.utils.forOwn,N=new e.Sphere,Qa=Math.sqrt(3),q=function(){this.root=null;this.keysToLeaves=Object.create(null)};q.prototype.putSpheres=function(c){var b=this;Pa(c,function(a,c){b.putSphere(c,a)})};q.prototype.putSphere=
function(c,b){var a=b.center,d=b.radius;!b||isNaN(d)||isNaN(a.x)?console.warn("Invalid sphere",b):(a._roundedX=1E-8*Math.round(a.x/1E-8),a._roundedY=1E-8*Math.round(a.y/1E-8),a._roundedZ=1E-8*Math.round(a.z/1E-8),this._putSphere(c,b))};q.prototype._putSphere=function(c,b){var a=this,d=b.center,g=this.root,l=d._roundedX,e=d._roundedY,f=d._roundedZ;if(c in this.keysToLeaves)return this._updateSphere(c,b);if(g)if(g.isLeaf){d=this.root;var h=g.dataX,k=g.dataY,n=g.dataZ;if(h===l&&k===e&&n===f)this._insertIntoOctant(c,
b,g);else{var m=new p;g=m.cx=Math.round((h+l)/2);e=m.cy=Math.round((k+e)/2);f=m.cz=Math.round((n+f)/2);m.cr=Math.ceil(Math.max(Math.abs(g-h),Math.abs(e-k),Math.abs(f-n))+1E-5);this.root=m;d.forEachLeafSphere(function(b,c){return a._insertIntoOctant(c,b,m)});this._insertIntoOctant(c,b,m)}}else this._expandToCoverPoint(l,e,f),this._insertIntoOctant(c,b,this.root);else d=new p,d.isLeaf=!0,d.addSphereData(c,b),this.root=d,this.keysToLeaves[c]=d};q.prototype._expandToCoverPoint=function(c,b,a){for(;!this.root.containsPoint(c,
b,a);){var d=this.root,g=d.cx,l=d.cy,e=d.cz,f=d.cr,h=new p;h.maxRadius=d.maxRadius;h.sphereCount=d.sphereCount;h.leafCount=d.leafCount;h.cx=g+f*(c<g?-1:1);h.cy=l+f*(b<l?-1:1);h.cz=e+f*(a<e?-1:1);h.cr=2*f;g=h.getSubOctantIndexForPoint(g,l,e);d.parent=h;d.index=g;h[g]=d;this.root=h}};q.prototype._insertIntoOctant=function(c,b,a){var d=b.center,g=b.radius,l=d._roundedX,e=d._roundedY;d=d._roundedZ;if(a.isLeaf){var f=a.dataX,h=a.dataY,k=a.dataZ;if(l===f&&e===h&&d===k){a.addSphereData(c,b);for(b=a.parent;b;b=
b.parent)g>b.maxRadius&&(b.maxRadius=g);this.keysToLeaves[c]=a}else g=Ra(a),a.parent[a.index]=g,g.addOctantForPoint(a,f,h,k),this._insertIntoOctant(c,b,g)}else{a.sphereCount++;f=a.getSubOctantIndexForPoint(l,e,d);if(f=a[f])return this._insertIntoOctant(c,b,f);f=new p;f.isLeaf=!0;a.addOctantForPoint(f,l,e,d);f.addSphereData(c,b);for(a=f.parent;a;a=a.parent)g>a.maxRadius&&(a.maxRadius=g),a.leafCount++;this.keysToLeaves[c]=f}};q.prototype.removeSphere=function(c){var b=this.keysToLeaves[c];if(b){for(var a=
b.parent;a;)a.sphereCount--,a=a.parent;if(1<b.sphereCount)b.removeSphereData(c),b.updateMaxRadii();else{a=b;do{var d=a.parent;(b=d)&&(d[a.index]=null);a=a.parent}while(a&&0===a.sphereCount);if(!b){this.root=null;return}d=null;for(a=b;a;)a.leafCount--,1===a.leafCount&&(d=a),a=a.parent;d?(a=this._findSingleLeaf(d),(b=d.parent)?(b.addOctantForPoint(a,a.cx,a.cy,a.cz),b.updateMaxRadii()):this.root=a):b.updateMaxRadii()}delete this.keysToLeaves[c]}};q.prototype._updateSphere=function(c,b){var a=this.keysToLeaves[c],
d=b.center,g=d._roundedX,l=d._roundedY;d=d._roundedZ;if(a.containsPoint(g,l,d)){var e=g!==a.dataX||l!==a.dataY||d!==a.dataZ;1<a.sphereCount&&e?(a.removeSphereData(c),a.updateMaxRadii(),this._insertIntoOctant(c,b,a)):(e&&(a.dataX=g,a.dataY=l,a.dataZ=d),b.radius!==a.maxRadius&&a.updateMaxRadii())}else this.removeSphere(c),this._putSphere(c,b)};q.prototype._findSingleLeaf=function(c){function b(a){a.isLeaf&&(d=a)}function a(a){d=null;this.walkBranch(a,b);return d}var d;this._findSingleLeaf=a;return a.call(this,
c)};q.prototype.walkTree=function(c){this.root&&this.walkBranch(this.root,c)};q.prototype.walkBranch=function(c,b){if(!1!==b(c)&&!c.isLeaf)for(var a=0;8>a;a++)null!==c[a]&&this.walkBranch(c[a],b)};q.prototype.forEachSphereOnRay=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};q.prototype.forEachIntersectingSphere=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};q.prototype._forEachMatchingSphere=function(c,b,a){function d(d,l){c(d)&&
b.call(a,d,l)}this.walkTree(function(a){if(a.isLeaf)a.forEachLeafSphere(d);else if(N.center.set(a.cx,a.cy,a.cz),N.radius=a.cr*Qa+a.maxRadius,!c(N))return!1;return!0})};var p=function(){};p.prototype.containsPoint=function(c,b,a){var d=this.cx,g=this.cy,l=this.cz,e=this.cr;return c>=d-e&&c<d+e&&b>=g-e&&b<g+e&&a>=l-e&&a<l+e};p.prototype.getSubOctantIndexForPoint=function(c,b,a){return(a<this.cz?0:4)+(b<this.cy?0:2)+(c<this.cx?0:1)};p.prototype.addOctantForPoint=function(c,b,a,d){var g=this.getSubOctantIndexForPoint(b,
a,d),e=this.cr/2;c.parent=this;c.index=g;c.cx=this.cx+e*(b<this.cx?-1:1);c.cy=this.cy+e*(a<this.cy?-1:1);c.cz=this.cz+e*(d<this.cz?-1:1);c.cr=e;return this[g]=c};p.prototype.findMaxSphereRadius=function(){var c=0;if(this.isLeaf){var b=this.data;if(1<this.sphereCount)for(var a in b){var d=b[a].radius;d>c&&(c=d)}else c=b.radius}else for(b=0;8>b;b++)null!==this[b]&&this[b].maxRadius>c&&(c=this[b].maxRadius);return c};p.prototype.updateMaxRadii=function(){var c=this.findMaxSphereRadius();if(c>this.maxRadius)for(var b=
this;b;)c>b.maxRadius&&(b.maxRadius=c),b=b.parent;else c<this.maxRadius&&(this.maxRadius=c,this.parent&&this.parent.updateMaxRadii())};p.prototype.addSphereData=function(c,b){var a=this.sphereCount++;if(0===a){this.leafCount=1;this.data=b;this.dataKey=c;c=b.center;a=c._roundedY;var d=c._roundedZ;this.dataX=c._roundedX;this.dataY=a;this.dataZ=d}else 1===a?(a=this.data,d=this.data=Object.create(null),d[this.dataKey]=a,d[c]=b,this.dataKey=null):1<a&&(this.data[c]=b);b.radius>this.maxRadius&&(this.maxRadius=
b.radius)};p.prototype.removeSphereData=function(c){var b=this.data;if(b){var a=this.sphereCount--;if(2<a)delete b[c];else if(2===a)for(var d in b){if(d!==c){this.dataKey=d;this.data=b[d];break}}else this.data=null}};p.prototype.forEachLeafSphere=function(c,b){var a=this.data;if(a)if(1<this.sphereCount)for(var d in a)c.call(b,a[d],d);else c.call(b,a,this.dataKey)};r(p.prototype,{parent:null,index:-1,cx:0,cy:0,cz:0,cr:0,0:null,1:null,2:null,3:null,4:null,5:null,6:null,7:null,isLeaf:!1,data:null,dataKey:null,
dataX:0,dataY:0,dataZ:0,sphereCount:0,leafCount:0,maxRadius:0});var Ra=function(){var c="parent index cx cy cz cr sphereCount leafCount maxRadius".split(" ");return function(b){for(var a=new p,d=c.length;d--;)a[c[d]]=b[c[d]];return a}}(),E=k.utils.assign,O=new e.Vector2,v=new e.Vector3,ua=new e.Raycaster,H=function(c){function b(a){c.call(this,a);this._object3DFacadesById=Object.create(null);this._onBgClick=this._onBgClick.bind(this)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=
b;b.prototype.afterUpdate=function(){var a=this.width,b=this.height,g=this.antialias,l=this.backgroundColor,f=this.contextAttributes,k=this._element,h=this._threeRenderer,m=this.rendererClass||e.WebGLRenderer;h&&h instanceof m||(h&&h.dispose(),f=E({alpha:!0,antialias:g},f),(h=k.getContext("webgl2",f)||void 0)||console.info("webgl2 init failed, trying webgl"),h=this._threeRenderer=new m(E({canvas:k,context:h},f)));f=this.shadows;h.shadowMap.enabled=!!f;f&&"object"===typeof f&&E(h.shadowMap,f);l!==
this._bgColor&&(h.setClearColor(new e.Color(l||0),null!=l?1:0),this._bgColor=l);h.outputEncoding=this.outputEncoding||e.LinearEncoding;h.toneMapping=this.toneMapping||e.NoToneMapping;this._updateDrawingBufferSize(a,b,this.pixelRatio||window.devicePixelRatio||1);c.prototype.afterUpdate.call(this)};b.prototype.describeChildren=function(){return[this._getCameraDef(),this._getSceneDef()]};b.prototype._getCameraDef=function(){return E({key:"camera",facade:ka,aspect:this.width/this.height},this.camera)};
b.prototype._getSceneDef=function(){return{key:"scene",facade:ta,lights:this.lights,objects:this.objects,fog:this.fog,background:this.background,environment:this.environment,onClick:this.onBackgroundClick?this._onBgClick:null}};b.prototype._updateDrawingBufferSize=function(a,b,c){var d=this._threeRenderer;d.getSize(O);O.width===a&&O.height===b&&d.getPixelRatio()===c||d.setDrawingBufferSize(a,b,c)};b.prototype.doRender=function(){function a(a,d){a.call(this._object3DFacadesById[d],e,b,c)}var b=this.getChildByKey("scene").threeObject,
c=this.getChildByKey("camera").threeObject,e=this._threeRenderer,f=this.eventRegistry;f.forEachListenerOfType("beforerender",a,this);e.render(b,c);f.forEachListenerOfType("afterrender",a,this);if(f=this.onStatsUpdate){var k=e.info,h=k.memory;k=k.render;h={"WebGL Draw Calls":k.calls,"WebGL Geometries":h.geometries,"WebGL Textures":h.textures,"WebGL Triangles":k.triangles};k.points&&(h["WebGL Points"]=k.points);k.lines&&(h["WebGL Lines"]=k.lines);f(h)}};b.prototype.getFacadeUserSpaceXYZ=function(a){a=
a.threeObject.matrixWorld.elements;return this.projectWorldPosition(a[12],a[13],a[14])};b.prototype.projectWorldPosition=function(a,b,c){v.set(a,b,c);a=this.getChildByKey("camera");a.updateMatrices();a=a.threeObject;v.applyMatrix4(a.matrixWorldInverse);b=v.length()*(0<v.z?-1:1);v.applyMatrix4(a.projectionMatrix);return new e.Vector3((v.x+1)*this.width/2,(1-v.y)*this.height/2,b)};b.prototype._normalizePointerEvent=function(a){if(!a.ray){var b=a;if(a.touches){var g=/^touch(end|cancel)$/.test(a.type)?
a.changedTouches:a.touches;1===g.length&&(b=g[0])}var e=a.target.getBoundingClientRect();g=((b.clientX||0)-(e.left||0))/(e.width||this.width)*2-1;b=((b.clientY||0)-(e.top||0))/(e.height||this.height)*-2+1;e=this.getChildByKey("camera");e.updateMatrices();a.ray=e.getRayAtProjectedCoords(g,b)}c.prototype._normalizePointerEvent.call(this,a)};b.prototype.getFacadesAtEvent=function(a,b){return a.ray?this.getFacadesOnRay(a.ray,b):null};b.prototype.getFacadesOnRay=function(a,b){var c=this,d=this._updateOctree(),
e=null;d&&(ua.ray=a,d.forEachSphereOnRay(a,function(a,d){(a=(d=(a=c._object3DFacadesById)&&a[d])&&(!b||b(d))&&d.raycast&&d.raycast(ua))&&a[0]&&(a[0].facade=d,(e||(e=[])).push(a[0]))}));return e};b.prototype._updateOctree=function(){var a=this._boundingSphereOctree,b=this._octreeChangeset;if(b){a||(a=this._boundingSphereOctree=new q);var c=b.remove;b=b.put;if(c)for(var e in c)a.removeSphere(e);if(b)for(var f in b)e=this._object3DFacadesById[f],!e||e.isDestroying||c&&c[f]||((e=e.getBoundingSphere&&
e.getBoundingSphere())?a.putSphere(f,e):a.removeSphere(f));this._octreeChangeset=null}return a};b.prototype._queueForOctreeChange=function(a,b){var c=this._octreeChangeset||(this._octreeChangeset={});(c[a]||(c[a]=Object.create(null)))[b.$facadeId]=b};b.prototype._onBgClick=function(a){if(a.target===a.currentTarget)this.onBackgroundClick(a)};b.prototype.destructor=function(){c.prototype.destructor.call(this);this._threeRenderer.dispose()};return b}(k.WorldBaseFacade);H.prototype._notifyWorldHandlers=
E(Object.create(k.WorldBaseFacade.prototype._notifyWorldHandlers),{getCameraPosition:function(c,b){b.setFromMatrixPosition(this.getChildByKey("camera").threeObject.matrixWorld)},getCameraFacade:function(c,b){b.callback(this.getChildByKey("camera"))},getSceneFacade:function(c,b){b.callback(this.getChildByKey("scene"))},projectWorldPosition:function(c,b){c=b.worldPosition;b.callback(this.projectWorldPosition(c.x,c.y,c.z))},object3DAdded:function(c){this._object3DFacadesById[c.$facadeId]=c;this._queueForOctreeChange("put",
c)},object3DBoundsChanged:function(c){this._queueForOctreeChange("put",c)},object3DRemoved:function(c){delete this._object3DFacadesById[c.$facadeId];this._queueForOctreeChange("remove",c)},rayPointerMotion:function(c,b){var a=new MouseEvent("mousemove");a.isRayEvent=!0;a.ray=b;a.eventSource=c;this._onPointerMotionEvent(a)},rayPointerAction:function(c,b){var a=new ("wheel"===b.type?WheelEvent:MouseEvent)(b.type,b);a.isRayEvent=!0;a.ray=b.ray;a.eventSource=c;this._onPointerActionEvent(a)}});var Sa=
"onMouseOver onMouseOut onMouseMove onMouseDown onMouseUp onClick onDoubleClick".split(" ");r=function(c){function b(a){var b=new e.Object3D;b.isRenderable=!1;b.$troikaVisible=b.visible;Object.defineProperty(b,"visible",Ta);c.call(this,a,b);this.notifyWorld("instanceableAdded")}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={instancedThreeObject:{configurable:!0}};a.instancedThreeObject.set=function(a){a!==this._instancedThreeObject&&(this._instancedThreeObject=
a,this.notifyWorld("instanceableChanged"),this._boundsChanged=!0)};a.instancedThreeObject.get=function(){return this._instancedThreeObject};b.prototype.setInstanceUniform=function(a,b){var c=this._instanceUniforms||(this._instanceUniforms=Object.create(null));c[a]!==b&&(c[a]=b,this.notifyWorld("instanceableUniformChanged",a))};b.prototype.updateMatrices=function(){var a=this._worldMatrixVersion;c.prototype.updateMatrices.call(this);this._worldMatrixVersion!==a&&this.threeObject.$troikaVisible&&this.notifyWorld("instanceableMatrixChanged")};
b.prototype.destructor=function(){this.notifyWorld("instanceableRemoved");c.prototype.destructor.call(this)};b.prototype.getGeometry=function(){var a=this.instancedThreeObject;return a&&a.geometry};b.prototype.raycast=function(a){var b=this.instancedThreeObject,c=this.threeObject;if(b&&c){var d=b.matrixWorld;b.matrixWorld=c.matrixWorld;a=this._raycastObject(b,a);b.matrixWorld=d;return a}return null};Object.defineProperties(b.prototype,a);return b}(m);var Ta={set:function(c){c!==this.$troikaVisible&&
(this.$troikaVisible=c,this.$facade.notifyWorld("instanceableChanged"))},get:function(){return this.$troikaVisible}};k.utils.assign(r.prototype,{_lastInstancedMatrixVersion:-1,_instancedThreeObject:null});var P=new e.BufferGeometry,Ua=new e.MeshBasicMaterial,Q={basic:e.MeshBasicMaterial,depth:e.MeshDepthMaterial,distance:e.MeshDistanceMaterial,lambert:e.MeshLambertMaterial,matcap:e.MeshMatcapMaterial,normal:e.MeshNormalMaterial,phong:e.MeshPhongMaterial,physical:e.MeshPhysicalMaterial,standard:e.MeshStandardMaterial,
toon:e.MeshToonMaterial},w=function(c){function b(a){c.call(this,a,new e.Mesh(P,Ua));this.material="standard";this.autoDisposeMaterial=this.autoDisposeGeometry=!1;this._dirtyMtlProps=null}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate=function(){var a=this.geometry,b=this.material,g=this.threeObject;(a||P)!==g.geometry&&(this.autoDisposeGeometry&&g.geometry.dispose(),g.geometry=a||P);b!==this._lastMtl&&(this._lastMtl=b,"string"===typeof b?
b=new (Q[b]||e.MeshStandardMaterial):b&&b.isMaterial||(b="function"===typeof b?new b:new e.MeshStandardMaterial),g.material!==b&&(this.autoDisposeMaterial&&g.material.dispose(),g.material=b));if(a=this._dirtyMtlProps)g.material.setValues(a),this._dirtyMtlProps=null;c.prototype.afterUpdate.call(this)};b.prototype.destructor=function(){this.autoDisposeGeometry&&this.threeObject.geometry.dispose();this.autoDisposeMaterial&&this.threeObject.material.dispose();c.prototype.destructor.call(this)};return b}(m),
Va={type:1,id:1,uuid:1,version:1};Object.keys(Q).forEach(function(c){var b=new Q[c];c=function(a){b.hasOwnProperty(a)&&!Va.hasOwnProperty(a)&&Object.defineProperty(w.prototype,"material."+a,{enumerable:!0,configurable:!0,get:function(){var b=this._dirtyMtlProps;return b&&a in b?b[a]:this.threeObject.material[a]},set:function(b){(this._dirtyMtlProps||(this._dirtyMtlProps=Object.create(null)))[a]=b}})};for(var a in b)c(a)});var va=k.utils.memoize(function(){return new e.BoxBufferGeometry(1,1,1,1,1)}),
Wa=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},width:{configurable:!0},height:{configurable:!0},depth:{configurable:!0}};a.geometry.get=function(){return va()};a.width.set=function(a){this.scaleX=a};a.width.get=function(){return this.scaleX};a.height.set=function(a){this.scaleY=a};a.height.get=function(){return this.scaleY};a.depth.set=function(a){this.scaleZ=a};a.depth.get=
function(){return this.scaleZ};Object.defineProperties(b.prototype,a);return b}(w),wa=Object.create(null,[["low",32],["medium",64],["high",128]].reduce(function(c,b){var a=b[1];c[b[0]]={get:k.utils.memoize(function(){return(new e.CircleBufferGeometry(1,a)).rotateX(-Math.PI/2)})};return c},{})),Xa=function(c){function b(a){c.call(this,a);this["material.side"]=this["material.shadowSide"]=e.DoubleSide}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},
radius:{configurable:!0}};a.geometry.get=function(){return wa[this.detail]||wa.medium};a.radius.set=function(a){this.scaleX=this.scaleZ=a};a.radius.get=function(){return this.scaleX};Object.defineProperties(b.prototype,a);return b}(w),Ya=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},size:{configurable:!0}};a.geometry.get=function(){return va()};a.size.set=function(a){this.scale=
a};a.size.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(w),Za=k.utils.memoize(function(){return(new e.PlaneBufferGeometry(1,1,1,1)).rotateX(-Math.PI/2)}),$a=function(c){function b(a){c.call(this,a);this["material.side"]=this["material.shadowSide"]=e.DoubleSide}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},width:{configurable:!0},depth:{configurable:!0}};a.geometry.get=function(){return Za()};
a.width.set=function(a){this.scaleX=a};a.width.get=function(){return this.scaleX};a.depth.set=function(a){this.scaleZ=a};a.depth.get=function(){return this.scaleZ};Object.defineProperties(b.prototype,a);return b}(w),xa=Object.create(null,[["low",16,12],["medium",32,24],["high",64,48]].reduce(function(c,b){var a=b[1],d=b[2];c[b[0]]={get:k.utils.memoize(function(){return new e.SphereBufferGeometry(1,a,d)})};return c},{})),ab=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=
Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},radius:{configurable:!0}};a.geometry.get=function(){return xa[this.detail]||xa.medium};a.radius.set=function(a){this.scale=a};a.radius.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(w),I=function(c){function b(a){var b=this;c.call(this,a);this._onCanvasRef=function(a){var c=b.context.onCanvasRef;c&&c(a);(c=b.props.onCanvasRef)&&c(a)}}c&&(b.__proto__=c);b.prototype=Object.create(c&&
c.prototype);b.prototype.constructor=b;b.prototype.render=function(){var a=this.props,b=this.context;return ha["default"].createElement(c,k.utils.assign({},a,{onCanvasRef:this._onCanvasRef,canvasStyle:a.canvasStyle||b.canvasStyle,worldFacade:a.worldFacade||b.worldFacade||H,worldProps:k.utils.assign({antialias:a.antialias,rendererClass:a.rendererClass,backgroundColor:a.backgroundColor,background:a.background,environment:a.environment,outputEncoding:a.outputEncoding,toneMapping:a.toneMapping,shadows:a.shadows,
camera:a.camera,lights:a.lights,objects:a.objects,fog:a.fog,onBackgroundClick:a.onBackgroundClick},b.worldProps,a.worldProps)}),a.children)};return b}(k.ReactCanvasBase);I.displayName="Canvas3D";I.propTypes=k.utils.assignIf({backgroundColor:n["default"].any,background:n["default"].any,environment:n["default"].any,outputEncoding:n["default"].number,toneMapping:n["default"].number,lights:n["default"].array,camera:n["default"].object,objects:n["default"].oneOfType([n["default"].array,n["default"].object]).isRequired,
antialias:n["default"].bool,onBackgroundClick:n["default"].func,rendererClass:n["default"].func},k.ReactCanvasBase.commonPropTypes);I.contextType=ha["default"].createContext({worldFacade:H,worldProps:{},onCanvasRef:null,canvasStyle:null});Object.defineProperty(f,"Facade",{enumerable:!0,get:function(){return k.Facade}});Object.defineProperty(f,"ListFacade",{enumerable:!0,get:function(){return k.ListFacade}});Object.defineProperty(f,"ParentFacade",{enumerable:!0,get:function(){return k.ParentFacade}});
Object.defineProperty(f,"createDerivedMaterial",{enumerable:!0,get:function(){return x.createDerivedMaterial}});f.AmbientLight3DFacade=ma;f.BoxFacade=Wa;f.Canvas3D=I;f.CircleFacade=Xa;f.CubeFacade=Ya;f.DirectionalLight3DFacade=na;f.Group3DFacade=la;f.HemisphereLight3DFacade=qa;f.HtmlOverlay3DFacade=Ka;f.Instanceable3DFacade=r;f.InstancingManager=M;f.MeshFacade=w;f.Object3DFacade=m;f.OrthographicCamera3DFacade=A;f.PerspectiveCamera3DFacade=ka;f.PlaneFacade=$a;f.PointLight3DFacade=pa;f.RectAreaLight3DFacade=
La;f.Scene3DFacade=ta;f.SphereFacade=ab;f.SpotLight3DFacade=oa;f.World3DFacade=H;f.makeWorldTextureProvider=function(c){return function(b){function a(a){var c=this,d=new e.CanvasTexture;b.call(this,a,d);this.worldTexture=d;var f=this._refireAsInnerEvent.bind(this);Sa.forEach(function(a){function b(a){f(a);d&&d.call(this,a)}var d;c[a]=b;Object.defineProperty(c,a,{set:function(a){d=a},get:function(){return b}})})}b&&(a.__proto__=b);a.prototype=Object.create(b&&b.prototype);a.prototype.constructor=a;
a.prototype.afterUpdate=function(){var a=this,c=this._worldFacade,e=this.textureWorld;c&&e&&c instanceof e.facade||(c&&(c.onAfterRender=null,c.destructor()),e&&(this.worldTexture.dispose(),c=document.createElement("canvas"),c.width=c.height=2,this.worldTexture.image=c,c=this._worldFacade=new e.facade(c),c.onAfterRender=function(){a.worldTexture.needsUpdate=!0;a.notifyWorld("needsRender")}));c&&(c.renderingScheduler=this._getOuterWorld().renderingScheduler,k.utils.assign(c,e),c.afterUpdate());b.prototype.afterUpdate.call(this)};
a.prototype._refireAsInnerEvent=function(a){var b=this._worldFacade;if(b){var c=a.intersection&&a.intersection.uv,d=c?Math.round(c.x*b.width):-1;b=c?Math.round((1-c.y)*b.height):-1;a=a.nativeEvent||a;c=document.createEvent("MouseEvents");c.initMouseEvent(a.type,!0,!0,window,a.detail,d,b,d,b,a.ctrlKey,a.altKey,a.shiftKey,a.metaKey,a.button,null);this.worldTexture.image.dispatchEvent(c)}};a.prototype._getOuterWorld=function(){for(var a=this;a&&!a.isWorld;)a=a.parent;return a};a.prototype.destructor=
function(){var a=this._worldFacade;a&&(a.onAfterRender=null,a.destructor());this.worldTexture.dispose();b.prototype.destructor.call(this)};return a}(c)};Object.defineProperty(f,"__esModule",{value:!0})})
b;b.prototype.afterUpdate=function(){this.updateMatrices();this._checkBoundsChange();this._worldMatrixVersion>this._worldMatrixVersionAfterLastUpdate&&(this.shouldUpdateChildren()||this.traverse(function(a,d){a!==d&&a.updateMatrices&&(a.updateMatrices(),a._checkBoundsChange())},this),this._worldMatrixVersionAfterLastUpdate=this._worldMatrixVersion);c.prototype.afterUpdate.call(this);this._flushQueuedChildRemovals()};b.prototype.updateMatrices=function(){var a=this.threeObject,d=this._parentObject3DFacade;
if(this._matrixChanged){a.matrix.compose(a.position,a.quaternion,a.scale);this._matrixChanged=!1;var b=!0}else b=d&&d._worldMatrixVersion>this._worldMatrixVersion;if(b){d?a.matrixWorld.multiplyMatrices(d.threeObject.matrixWorld,a.matrix):a.matrixWorld.copy(a.matrix);a=a.children;d=0;for(b=a.length;d<b;d++)a[d].$facade||a[d].updateMatrixWorld(!0);this.markWorldMatrixDirty()}};b.prototype.markWorldMatrixDirty=function(){this._worldMatrixVersion=++Ia;this._boundsChanged=!0};b.prototype._checkBoundsChange=
function(){var a=this._boundsChanged;if(!a){var d=this._getGeometryBoundingSphere();d&&d.version!==this._lastGeometrySphereVersion&&(a=!0,this._lastGeometrySphereVersion=d.version)}a&&(this.notifyWorld("object3DBoundsChanged"),this._boundsChanged=!1)};b.prototype.getWorldPosition=function(a){this.updateMatrices();return(a||new e.Vector3).setFromMatrixPosition(this.threeObject.matrixWorld)};b.prototype.getCameraPosition=function(a){a=a||new e.Vector3;this.notifyWorld("getCameraPosition",a);return a};
b.prototype.getCameraFacade=function(){t.value=null;this.notifyWorld("getCameraFacade",t);return t.value};b.prototype.getCameraDistance=function(){var a=this.getCameraPosition(Ga),d=this.getWorldPosition(ja);return a.distanceTo(d)};b.prototype.getProjectedPosition=function(a,d,b){this.updateMatrices();t.value=null;t.worldPosition=ja.set(a||0,d||0,b||0).applyMatrix4(this.threeObject.matrixWorld);this.notifyWorld("projectWorldPosition",t);return t.value};b.prototype.getSceneFacade=function(){t.value=
null;this.notifyWorld("getSceneFacade",t);return t.value};b.prototype.getBoundingSphere=function(){var a=this._getGeometryBoundingSphere();if(!a)return null;this.updateMatrices();var d=this._boundingSphere;d||(d=this._boundingSphere=new e.Sphere);if(d._geometrySphereVersion!==a.version||d._worldMatrixVersion!==this._worldMatrixVersion)d.copy(a),d.applyMatrix4(this.threeObject.matrixWorld),d._worldMatrixVersion=this._worldMatrixVersion,d._geometrySphereVersion=a.version;return d};b.prototype._getGeometryBoundingSphere=
function(){var a=this.getGeometry();if(a){var d=a.boundingSphere,b=!1;if(d)if(a.isBufferGeometry){var c=a.attributes.position;c&&d._posAttrVersion!==c.version&&(a.computeBoundingSphere(),d._posAttrVersion=c.version,b=!0)}else a._lastBoundingSphere&&d.equals(a._lastBoundingSphere)||(a._lastBoundingSphere=d.clone(),b=!0);else a.computeBoundingSphere(),d=a.boundingSphere,b=!0;b&&(d.version=++Ja);return d}return null};b.prototype.getGeometry=function(){var a=this.threeObject;return a&&a.geometry};b.prototype.raycast=
function(a){return this.threeObject?this._raycastObject(this.threeObject,a):null};b.prototype._raycastObject=function(a,d){if(a.visible){D.length=0;var b=null,c=this.raycastSide;null!=c&&(b=a.material.side,a.material.side=c);a.raycast(d,D);null!==b&&(a.material.side=b);if(D.length)return D.sort(ya),D.slice()}return null};b.prototype._addToThreeObjectTree=function(){var a=this._parentObject3DFacade;a&&this.threeObject.parent!==a.threeObject&&(a.threeObject.add(this.threeObject),a._addToThreeObjectTree())};
b.prototype._queueRemoveChildObject3D=function(a){(this._removeChildIds||(this._removeChildIds=Object.create(null)))[a]=!0};b.prototype._flushQueuedChildRemovals=function(){if(this._removeChildIds){var a=this.threeObject,d=this._removeChildIds;a.children=a.children.filter(function(a){return a.id in d?(a.parent=null,a.dispatchEvent(Ha),!1):!0});var b=this._parentObject3DFacade;S(a)&&b&&b.threeObject===a.parent&&(b._queueRemoveChildObject3D(a.id),b._flushQueuedChildRemovals());this._removeChildIds=
null}};b.prototype.destructor=function(){this.notifyWorld("object3DRemoved");var a=this._parentObject3DFacade;a&&a._queueRemoveChildObject3D(this.threeObject.id);delete this.threeObject;c.prototype.destructor.call(this)};return b}(k.PointerEventTarget);["castShadow","receiveShadow","renderOrder","visible"].forEach(function(c){Object.defineProperty(m.prototype,c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});m.prototype.raycastSide=null;ia({position:{x:"x",y:"y",
z:"z"},scale:{x:"scaleX",y:"scaleY",z:"scaleZ"},rotation:{x:"rotateX",y:"rotateY",z:"rotateZ",order:"rotateOrder"},quaternion:{x:"quaternionX",y:"quaternionY",z:"quaternionZ",w:"quaternionW"}},function(c,b){ia(c,function(a,d){Object.defineProperty(m.prototype,a,{get:(new Function("return function "+a+"$get() {\n return this.threeObject."+b+"."+d+"\n}"))(),set:(new Function("return function "+a+"$set(value) {\n //let obj = this.threeObject."+b+"\n if (this.threeObject."+b+"."+d+" !== value) {\n this.threeObject."+
b+"."+d+" = value\n if (!this._matrixChanged) {\n this._matrixChanged = true\n }\n }\n}"))()})})});Object.defineProperty(m.prototype,"scale",{get:function(){return this.threeObject.scale.x},set:function(c){var b=this.threeObject.scale;if(c!==b.x||c!==b.y||c!==b.z)b.x=b.y=b.z=c,this._matrixChanged||(this._matrixChanged=!0)}});Object.defineProperty(m.prototype,"isObject3DFacade",{value:!0});A(m.prototype,{threeObject:null,_parentObject3DFacade:null,_removeChildIds:null,_matrixChanged:!0,
_worldMatrixVersion:-1,_worldMatrixVersionAfterLastUpdate:-1,_boundingSphereChanged:!1});k.Facade.defineEventProperty(m,"onBeforeRender","beforerender");k.Facade.defineEventProperty(m,"onAfterRender","afterrender");var za=function(){},X=new e.Raycaster,Ba=new e.Vector2,U=new e.Vector3,W=new e.Matrix4,B=new e.Quaternion,V=new e.Vector3(0,1,0),Aa=0,ka=T(e.PerspectiveCamera,["fov","aspect","near","far"],["focus","filmGauge","filmOffset"]);A=T(e.OrthographicCamera,"left right top bottom near far".split(" "));
var la=function(c){function b(a){var d=new e.Group;d.isRenderable=!1;c.call(this,a,d)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);return b.prototype.constructor=b}(m),Ka=function(c){function b(a){var d=new e.Object3D;d.isRenderable=!1;c.call(this,a,d);this.html=null;this.exact=!1;this.notifyWorld("addHtmlOverlay",this)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.destructor=function(){this.notifyWorld("removeHtmlOverlay",this);
c.prototype.destructor.call(this)};return b}(m),Y=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={color:{configurable:!0},shadow:{configurable:!0}};a.color.set=function(a){this.threeObject.color.set(a)};a.color.get=function(){return this.threeObject.color.getHex()};a.shadow.get=function(){return this.threeObject.shadow};a.shadow.set=function(a){k.utils.assignDeep(this.threeObject.shadow,a)};Object.defineProperties(b.prototype,
a);return b}(m);"intensity distance angle penumbra decay castShadow width height".split(" ").forEach(function(c){Object.defineProperty(Y.prototype,c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});var ma=y(e.AmbientLight),na=y(e.DirectionalLight,e.DirectionalLightHelper),oa=y(e.SpotLight,e.SpotLightHelper),pa=y(e.PointLight,e.PointLightHelper),qa=y(e.HemisphereLight,e.HemisphereLightHelper,{groundColor:{set:function(c){this.threeObject.groundColor.set(c)},get:function(){return this.threeObject.groundColor.getHex()}}}),
La=y(e.RectAreaLight),Ea="\ntroika_modelMatrix = mat4(\n %0.x, %1.x, %2.x, 0.0,\n %0.y, %1.y, %2.y, 0.0,\n %0.z, %1.z, %2.z, 0.0,\n %0.w, %1.w, %2.w, 1.0\n);\n".replace(/%/g,"troika_modelMatrixRow"),aa=/\bmodelMatrix\b/g,ba=/\bmodelViewMatrix\b/g,ca=/\bnormalMatrix\b/g,ra=/\buniform\s+(int|float|vec[234])\s+$/,F=function(c,b,a){return ra.test(a.substr(0,b))?c:"troika_"+c},Fa=function(c,b,a){return ra.test(a.substr(0,b))?c:"troika_vary_"+c},Z=new WeakMap,L=k.utils.assign,M=function(c){function b(a){c.call(this,
a);this._instanceables=Object.create(null);this._batchGeometryPool=new G;this._needsRebatch=!0;this.addEventListener("beforerender",this._setupBatchObjects.bind(this));this.addEventListener("afterrender",this._teardownBatchObjects.bind(this))}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.onNotifyWorld=function(a,d,b){var c=this._notifyWorldHandlers[d];if(c)c.call(this,a,b);else if(this.parent)this.parent.onNotifyWorld(a,d,b)};b.prototype._setupBatchObjects=
function(a,d,b){b=this._instanceables;a=this._batchObjectsByKey;var c=this._needsRebatch;if(!c)for(var g in a)if(this._getBatchKey(a[g][0].$troikaBatchBaseObj)!==g){c=!0;break}if(c){a=this._batchObjectsByKey=Object.create(null);g=this._batchGeometryPool;for(var e in b){c=b[e];var h=c.threeObject,f=c.instancedThreeObject;if(f&&h.visible){var k=this._getBatchKey(f),z=f.material.instanceUniforms,m=a[k]||(a[k]=[]),n=(k=m[m.length-1])&&k.geometry;if(!n||128===K(n)){k=this._getBatchObject(f);n=k.geometry;
for(var q=n._instanceAttrs.matrix,p=0;3>p;p++)q[p].version++;if(z)for(q=n._instanceAttrs.uniforms,p=z.length;p--;)q[z[p]].version++;m.push(k)}m=K(n);fa(n,m+1);q=n._instanceAttrs.matrix;h=h.matrixWorld.elements;q[0].setXYZW(m,h[0],h[4],h[8],h[12]);q[1].setXYZW(m,h[1],h[5],h[9],h[13]);q[2].setXYZW(m,h[2],h[6],h[10],h[14]);if(z)for(q=n._instanceAttrs.uniforms,h=z.length;h--;){p=z[h];n=q[p];var r=c._instanceUniforms;p=r&&p in r?r[p]:ea(f.material,p);da(n,m,p)}c._instancingBatchObject=k;c._instancingBatchAttrOffset=
m}else c._instancingBatchObject=c._instancingBatchAttrOffset=null}g.disposeUnused()}g=b=e=0;for(var t in a)for(c=a[t],d.children.push.apply(d.children,c),b++,f=c.length;f--;)e++,g+=K(c[f].geometry);this.notifyWorld("statsUpdate",{"Instancing Batch Groups":b,"Instancing Batches":e,"Instanced Objects":g});this._needsRebatch=!1};b.prototype._onInstanceAdded=function(a){this._instanceables[a.$facadeId]=a;this._needsRebatch=!0};b.prototype._onInstanceRemoved=function(a){delete this._instanceables[a.$facadeId];
this._needsRebatch=!0};b.prototype._onInstanceChanged=function(a){this._needsRebatch=!0};b.prototype._onInstanceMatrixChanged=function(a){if(!this._needsRebatch){var b=a.instancedThreeObject,c=a._instancingBatchObject,l=a._instancingBatchAttrOffset;b&&c&&this._getBatchKey(b)===this._getBatchKey(c)?(b=c.geometry._instanceAttrs.matrix,a=a.threeObject.matrixWorld.elements,b[0].setXYZW(l,a[0],a[4],a[8],a[12]).version++,b[1].setXYZW(l,a[1],a[5],a[9],a[13]).version++,b[2].setXYZW(l,a[2],a[6],a[10],a[14]).version++):
(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._onInstanceUniformChanged=function(a,b){if(!this._needsRebatch){var d=a.instancedThreeObject,c=a._instancingBatchObject;d&&c&&this._getBatchKey(d)===this._getBatchKey(c)?(d=c.geometry._instanceAttrs.uniforms[b],da(d,a._instancingBatchAttrOffset,a._instanceUniforms[b]),d.version++):(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._getBatchKey=function(a){var b=
this._batchKeysCache||(this._batchKeysCache=Object.create(null)),c=b&&b[a.id];if(!c){c=a.material;var l=c.instanceUniforms;c=a.geometry.id+"|"+c.id+"|"+(l?l.sort().join(","):"");b[a.id]=c}return c};b.prototype._getInstanceUniformSizes=function(a){var b=this._uniformSizesCache||(this._uniformSizesCache=new Map),c=b.get(a);c||(c=Object.create(null),a.instanceUniforms&&a.instanceUniforms.forEach(function(b){var d=ea(a,b);d=null==d?0:"number"===typeof d?1:d.isVector2?2:d.isVector3||d.isColor?3:d.isVector4?
4:Array.isArray(d)?d.length:0;0<d?c[b]=d:console.warn("Could not determine item size for uniform "+b)}),b.set(a,c));return c};b.prototype._getBatchObject=function(a){var b=a.geometry,c=a.material;if(!b.isBufferGeometry)throw Error("Instanceable proto object must use a BufferGeometry");var l=this._getBatchKey(a),u=this._getInstanceUniformSizes(c);b=this._batchGeometryPool.borrow(l,b,u);fa(b,0);var J=Ca(c),h,f;c=Object.create(a,{geometry:{value:b},material:{value:J},visible:{value:!0},frustumCulled:{value:!1},
customDepthMaterial:{get:function(){h||(h=J.getDepthMaterial(),h.isShaderMaterial=!0);return h}},customDistanceMaterial:{get:function(){f||(f=J.getDistanceMaterial(),f.isShaderMaterial=!0,f.uniforms=L({viewMatrix:{value:new e.Matrix4}},f.uniforms));return f}},modelViewMatrix:{value:function(){var a=new e.Matrix4;a.multiplyMatrices=function(a,b){f&&(f.uniforms.viewMatrix.value.copy(a),f.uniformsNeedUpdate=!0);return e.Matrix4.prototype.multiplyMatrices.call(this,a,b)};return a}()}});c.$troikaBatchBaseObj=
a;c.$troikaInstancingManager=this;return c};b.prototype._teardownBatchObjects=function(a,b,c){var d=this;this._batchGeometryPool.releaseAll();this._uniformSizesCache=this._batchKeysCache=null;b.children=b.children.filter(function(a){return a.$troikaInstancingManager!==d})};b.prototype.destructor=function(){var a=this._batchGeometryPool;a.releaseAll();a.disposeUnused();c.prototype.destructor.call(this)};return b}(la),G=function(){this._poolsByKey=Object.create(null)};G.prototype.borrow=function(c,
b,a){var d=this._poolsByKey;c=d[c]||(d[c]={geometries:[],firstFree:0});d=c.geometries[c.firstFree++];if(!d){d=new e.InstancedBufferGeometry;L(d,b);d.attributes=L({},b.attributes);b=d._instanceAttrs={matrix:[],uniforms:Object.create(null)};for(var g=0;3>g;g++){var l=new e.InstancedBufferAttribute(new Float32Array(512),4);l.setUsage?l.setUsage(35048):l.dynamic=!0;d.attributes["troika_modelMatrixRow"+g]=l;b.matrix[g]=l}for(var u in a)g=a[u],g=new e.InstancedBufferAttribute(new Float32Array(128*g),g),
g.setUsage?g.setUsage(35048):g.dynamic=!0,d.attributes["troika_"+u]=g,b.uniforms[u]=g;c.geometries.push(d)}return d};G.prototype.releaseAll=function(){var c=this._poolsByKey;if(c)for(var b in c)c[b].firstFree=0};G.prototype.disposeUnused=function(){var c=this._poolsByKey;if(c)for(var b in c){var a=c[b],d=a.firstFree;a=a.geometries;for(var g=d,l=a.length;g<l;g++){var e=a[g].attributes,f;for(f in e)e.hasOwnProperty(f)&&0!==f.indexOf("troika_")&&delete e[f];try{a[g].dispose()}catch(h){}a[g]._instanceAttrs=
null}a.length=d}};var r=M.prototype;r._notifyWorldHandlers={instanceableAdded:r._onInstanceAdded,instanceableRemoved:r._onInstanceRemoved,instanceableChanged:r._onInstanceChanged,instanceableMatrixChanged:r._onInstanceMatrixChanged,instanceableUniformChanged:r._onInstanceUniformChanged};var Ma={ambient:ma,directional:na,spot:oa,point:pa,hemisphere:qa},Na=[{distance:Infinity}],Oa=new e.Sphere(void 0,Infinity),sa=[null],ta=function(c){function b(a){var b=new e.Scene;b.autoUpdate=!1;c.call(this,a,b)}
c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={fog:{configurable:!0}};b.prototype.afterUpdate=function(){var a=this.threeObject;a.background=this.background||null;a.environment=this.environment||null;c.prototype.afterUpdate.call(this)};b.prototype.describeChildren=function(){var a={key:"instancingMgr",facade:M,children:this.objects},b=this.lights;b&&(a=[a],Array.isArray(b)||(sa[0]=b,b=sa),b.forEach(function(b,c){var d=b.facade||Ma[b.type];if("function"===
typeof d){var g=k.utils.assign({},b);delete g.type;g.key=b.key||"light"+c;g.facade=d;a.push(g)}}));return a};a.fog.set=function(a){var b=this._fogObj;if(a){var c="density"in a,d=c?e.FogExp2:e.Fog;b&&b instanceof d||(b=this._fogObj=new d);b.color.set(a.color);c?b.density=a.density:(b.near=a.near,b.far=a.far)}else b=this._fogObj=null;this.threeObject.fog=b};b.prototype.getBoundingSphere=function(){return Oa};b.prototype.raycast=function(a){return Na};Object.defineProperties(b.prototype,a);return b}(m);
r=k.utils.assign;var Pa=k.utils.forOwn,N=new e.Sphere,Qa=Math.sqrt(3),q=function(){this.root=null;this.keysToLeaves=Object.create(null)};q.prototype.putSpheres=function(c){var b=this;Pa(c,function(a,c){b.putSphere(c,a)})};q.prototype.putSphere=function(c,b){var a=b.center,d=b.radius;!b||isNaN(d)||isNaN(a.x)?console.warn("Invalid sphere",b):(a._roundedX=1E-8*Math.round(a.x/1E-8),a._roundedY=1E-8*Math.round(a.y/1E-8),a._roundedZ=1E-8*Math.round(a.z/1E-8),this._putSphere(c,b))};q.prototype._putSphere=
function(c,b){var a=this,d=b.center,g=this.root,l=d._roundedX,e=d._roundedY,f=d._roundedZ;if(c in this.keysToLeaves)return this._updateSphere(c,b);if(g)if(g.isLeaf){d=this.root;var h=g.dataX,k=g.dataY,n=g.dataZ;if(h===l&&k===e&&n===f)this._insertIntoOctant(c,b,g);else{var m=new p;g=m.cx=Math.round((h+l)/2);e=m.cy=Math.round((k+e)/2);f=m.cz=Math.round((n+f)/2);m.cr=Math.ceil(Math.max(Math.abs(g-h),Math.abs(e-k),Math.abs(f-n))+1E-5);this.root=m;d.forEachLeafSphere(function(b,c){return a._insertIntoOctant(c,
b,m)});this._insertIntoOctant(c,b,m)}}else this._expandToCoverPoint(l,e,f),this._insertIntoOctant(c,b,this.root);else d=new p,d.isLeaf=!0,d.addSphereData(c,b),this.root=d,this.keysToLeaves[c]=d};q.prototype._expandToCoverPoint=function(c,b,a){for(;!this.root.containsPoint(c,b,a);){var d=this.root,g=d.cx,l=d.cy,e=d.cz,f=d.cr,h=new p;h.maxRadius=d.maxRadius;h.sphereCount=d.sphereCount;h.leafCount=d.leafCount;h.cx=g+f*(c<g?-1:1);h.cy=l+f*(b<l?-1:1);h.cz=e+f*(a<e?-1:1);h.cr=2*f;g=h.getSubOctantIndexForPoint(g,
l,e);d.parent=h;d.index=g;h[g]=d;this.root=h}};q.prototype._insertIntoOctant=function(c,b,a){var d=b.center,g=b.radius,l=d._roundedX,e=d._roundedY;d=d._roundedZ;if(a.isLeaf){var f=a.dataX,h=a.dataY,k=a.dataZ;if(l===f&&e===h&&d===k){a.addSphereData(c,b);for(b=a.parent;b;b=b.parent)g>b.maxRadius&&(b.maxRadius=g);this.keysToLeaves[c]=a}else g=Ra(a),a.parent[a.index]=g,g.addOctantForPoint(a,f,h,k),this._insertIntoOctant(c,b,g)}else{a.sphereCount++;f=a.getSubOctantIndexForPoint(l,e,d);if(f=a[f])return this._insertIntoOctant(c,
b,f);f=new p;f.isLeaf=!0;a.addOctantForPoint(f,l,e,d);f.addSphereData(c,b);for(a=f.parent;a;a=a.parent)g>a.maxRadius&&(a.maxRadius=g),a.leafCount++;this.keysToLeaves[c]=f}};q.prototype.removeSphere=function(c){var b=this.keysToLeaves[c];if(b){for(var a=b.parent;a;)a.sphereCount--,a=a.parent;if(1<b.sphereCount)b.removeSphereData(c),b.updateMaxRadii();else{a=b;do{var d=a.parent;(b=d)&&(d[a.index]=null);a=a.parent}while(a&&0===a.sphereCount);if(!b){this.root=null;return}d=null;for(a=b;a;)a.leafCount--,
1===a.leafCount&&(d=a),a=a.parent;d?(a=this._findSingleLeaf(d),(b=d.parent)?(b.addOctantForPoint(a,a.cx,a.cy,a.cz),b.updateMaxRadii()):this.root=a):b.updateMaxRadii()}delete this.keysToLeaves[c]}};q.prototype._updateSphere=function(c,b){var a=this.keysToLeaves[c],d=b.center,g=d._roundedX,l=d._roundedY;d=d._roundedZ;if(a.containsPoint(g,l,d)){var e=g!==a.dataX||l!==a.dataY||d!==a.dataZ;1<a.sphereCount&&e?(a.removeSphereData(c),a.updateMaxRadii(),this._insertIntoOctant(c,b,a)):(e&&(a.dataX=g,a.dataY=
l,a.dataZ=d),b.radius!==a.maxRadius&&a.updateMaxRadii())}else this.removeSphere(c),this._putSphere(c,b)};q.prototype._findSingleLeaf=function(c){function b(a){a.isLeaf&&(d=a)}function a(a){d=null;this.walkBranch(a,b);return d}var d;this._findSingleLeaf=a;return a.call(this,c)};q.prototype.walkTree=function(c){this.root&&this.walkBranch(this.root,c)};q.prototype.walkBranch=function(c,b){if(!1!==b(c)&&!c.isLeaf)for(var a=0;8>a;a++)null!==c[a]&&this.walkBranch(c[a],b)};q.prototype.forEachSphereOnRay=
function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};q.prototype.forEachIntersectingSphere=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};q.prototype._forEachMatchingSphere=function(c,b,a){function d(d,l){c(d)&&b.call(a,d,l)}this.walkTree(function(a){if(a.isLeaf)a.forEachLeafSphere(d);else if(N.center.set(a.cx,a.cy,a.cz),N.radius=a.cr*Qa+a.maxRadius,!c(N))return!1;return!0})};var p=function(){};p.prototype.containsPoint=function(c,
b,a){var d=this.cx,g=this.cy,l=this.cz,e=this.cr;return c>=d-e&&c<d+e&&b>=g-e&&b<g+e&&a>=l-e&&a<l+e};p.prototype.getSubOctantIndexForPoint=function(c,b,a){return(a<this.cz?0:4)+(b<this.cy?0:2)+(c<this.cx?0:1)};p.prototype.addOctantForPoint=function(c,b,a,d){var g=this.getSubOctantIndexForPoint(b,a,d),e=this.cr/2;c.parent=this;c.index=g;c.cx=this.cx+e*(b<this.cx?-1:1);c.cy=this.cy+e*(a<this.cy?-1:1);c.cz=this.cz+e*(d<this.cz?-1:1);c.cr=e;return this[g]=c};p.prototype.findMaxSphereRadius=function(){var c=
0;if(this.isLeaf){var b=this.data;if(1<this.sphereCount)for(var a in b){var d=b[a].radius;d>c&&(c=d)}else c=b.radius}else for(b=0;8>b;b++)null!==this[b]&&this[b].maxRadius>c&&(c=this[b].maxRadius);return c};p.prototype.updateMaxRadii=function(){var c=this.findMaxSphereRadius();if(c>this.maxRadius)for(var b=this;b;)c>b.maxRadius&&(b.maxRadius=c),b=b.parent;else c<this.maxRadius&&(this.maxRadius=c,this.parent&&this.parent.updateMaxRadii())};p.prototype.addSphereData=function(c,b){var a=this.sphereCount++;
if(0===a){this.leafCount=1;this.data=b;this.dataKey=c;c=b.center;a=c._roundedY;var d=c._roundedZ;this.dataX=c._roundedX;this.dataY=a;this.dataZ=d}else 1===a?(a=this.data,d=this.data=Object.create(null),d[this.dataKey]=a,d[c]=b,this.dataKey=null):1<a&&(this.data[c]=b);b.radius>this.maxRadius&&(this.maxRadius=b.radius)};p.prototype.removeSphereData=function(c){var b=this.data;if(b){var a=this.sphereCount--;if(2<a)delete b[c];else if(2===a)for(var d in b){if(d!==c){this.dataKey=d;this.data=b[d];break}}else this.data=
null}};p.prototype.forEachLeafSphere=function(c,b){var a=this.data;if(a)if(1<this.sphereCount)for(var d in a)c.call(b,a[d],d);else c.call(b,a,this.dataKey)};r(p.prototype,{parent:null,index:-1,cx:0,cy:0,cz:0,cr:0,0:null,1:null,2:null,3:null,4:null,5:null,6:null,7:null,isLeaf:!1,data:null,dataKey:null,dataX:0,dataY:0,dataZ:0,sphereCount:0,leafCount:0,maxRadius:0});var Ra=function(){var c="parent index cx cy cz cr sphereCount leafCount maxRadius".split(" ");return function(b){for(var a=new p,d=c.length;d--;)a[c[d]]=
b[c[d]];return a}}(),E=k.utils.assign,O=new e.Vector2,v=new e.Vector3,ua=new e.Raycaster,H=function(c){function b(a){c.call(this,a);this._object3DFacadesById=Object.create(null);this._onBgClick=this._onBgClick.bind(this)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate=function(){var a=this.width,b=this.height,g=this.antialias,l=this.backgroundColor,f=this.contextAttributes,k=this._element,h=this._threeRenderer,m=this.rendererClass||e.WebGLRenderer;
h&&h instanceof m||(h&&h.dispose(),f=E({alpha:!0,antialias:g},f),(h=k.getContext("webgl2",f)||void 0)||console.info("webgl2 init failed, trying webgl"),h=this._threeRenderer=new m(E({canvas:k,context:h},f)));f=this.shadows;h.shadowMap.enabled=!!f;f&&"object"===typeof f&&E(h.shadowMap,f);l!==this._bgColor&&(h.setClearColor(new e.Color(l||0),null!=l?1:0),this._bgColor=l);h.outputEncoding=this.outputEncoding||e.LinearEncoding;h.toneMapping=this.toneMapping||e.NoToneMapping;this._updateDrawingBufferSize(a,
b,this.pixelRatio||window.devicePixelRatio||1);c.prototype.afterUpdate.call(this)};b.prototype.describeChildren=function(){return[this._getCameraDef(),this._getSceneDef()]};b.prototype._getCameraDef=function(){return E({key:"camera",facade:ka,aspect:this.width/this.height},this.camera)};b.prototype._getSceneDef=function(){return{key:"scene",facade:ta,lights:this.lights,objects:this.objects,fog:this.fog,background:this.background,environment:this.environment,onClick:this.onBackgroundClick?this._onBgClick:
null}};b.prototype._updateDrawingBufferSize=function(a,b,c){var d=this._threeRenderer;d.getSize(O);O.width===a&&O.height===b&&d.getPixelRatio()===c||d.setDrawingBufferSize(a,b,c)};b.prototype.doRender=function(){function a(a,d){a.call(this._object3DFacadesById[d],e,b,c)}var b=this.getChildByKey("scene").threeObject,c=this.getChildByKey("camera").threeObject,e=this._threeRenderer,f=this.eventRegistry;f.forEachListenerOfType("beforerender",a,this);e.render(b,c);f.forEachListenerOfType("afterrender",
a,this);if(f=this.onStatsUpdate){var k=e.info,h=k.memory;k=k.render;h={"WebGL Draw Calls":k.calls,"WebGL Geometries":h.geometries,"WebGL Textures":h.textures,"WebGL Triangles":k.triangles};k.points&&(h["WebGL Points"]=k.points);k.lines&&(h["WebGL Lines"]=k.lines);f(h)}};b.prototype.getFacadeUserSpaceXYZ=function(a){a=a.threeObject.matrixWorld.elements;return this.projectWorldPosition(a[12],a[13],a[14])};b.prototype.projectWorldPosition=function(a,b,c){v.set(a,b,c);a=this.getChildByKey("camera");a.updateMatrices();
a=a.threeObject;v.applyMatrix4(a.matrixWorldInverse);b=v.length()*(0<v.z?-1:1);v.applyMatrix4(a.projectionMatrix);return new e.Vector3((v.x+1)*this.width/2,(1-v.y)*this.height/2,b)};b.prototype._normalizePointerEvent=function(a){if(!a.ray){var b=a;if(a.touches){var g=/^touch(end|cancel)$/.test(a.type)?a.changedTouches:a.touches;1===g.length&&(b=g[0])}var e=a.target.getBoundingClientRect();g=((b.clientX||0)-(e.left||0))/(e.width||this.width)*2-1;b=((b.clientY||0)-(e.top||0))/(e.height||this.height)*
-2+1;e=this.getChildByKey("camera");e.updateMatrices();a.ray=e.getRayAtProjectedCoords(g,b)}c.prototype._normalizePointerEvent.call(this,a)};b.prototype.getFacadesAtEvent=function(a,b){return a.ray?this.getFacadesOnRay(a.ray,b):null};b.prototype.getFacadesOnRay=function(a,b){var c=this,d=this._updateOctree(),e=null;d&&(ua.ray=a,d.forEachSphereOnRay(a,function(a,d){(a=(d=(a=c._object3DFacadesById)&&a[d])&&(!b||b(d))&&d.raycast&&d.raycast(ua))&&a[0]&&(a[0].facade=d,(e||(e=[])).push(a[0]))}));return e};
b.prototype._updateOctree=function(){var a=this._boundingSphereOctree,b=this._octreeChangeset;if(b){a||(a=this._boundingSphereOctree=new q);var c=b.remove;b=b.put;if(c)for(var e in c)a.removeSphere(e);if(b)for(var f in b)e=this._object3DFacadesById[f],!e||e.isDestroying||c&&c[f]||((e=e.getBoundingSphere&&e.getBoundingSphere())?a.putSphere(f,e):a.removeSphere(f));this._octreeChangeset=null}return a};b.prototype._queueForOctreeChange=function(a,b){var c=this._octreeChangeset||(this._octreeChangeset=
{});(c[a]||(c[a]=Object.create(null)))[b.$facadeId]=b};b.prototype._onBgClick=function(a){if(a.target===a.currentTarget)this.onBackgroundClick(a)};b.prototype.destructor=function(){c.prototype.destructor.call(this);this._threeRenderer.dispose()};return b}(k.WorldBaseFacade);H.prototype._notifyWorldHandlers=E(Object.create(k.WorldBaseFacade.prototype._notifyWorldHandlers),{getCameraPosition:function(c,b){b.setFromMatrixPosition(this.getChildByKey("camera").threeObject.matrixWorld)},getCameraFacade:function(c,
b){b.callback(this.getChildByKey("camera"))},getSceneFacade:function(c,b){b.callback(this.getChildByKey("scene"))},projectWorldPosition:function(c,b){c=b.worldPosition;b.callback(this.projectWorldPosition(c.x,c.y,c.z))},object3DAdded:function(c){this._object3DFacadesById[c.$facadeId]=c;this._queueForOctreeChange("put",c)},object3DBoundsChanged:function(c){this._queueForOctreeChange("put",c)},object3DRemoved:function(c){delete this._object3DFacadesById[c.$facadeId];this._queueForOctreeChange("remove",
c)},rayPointerMotion:function(c,b){var a=new MouseEvent("mousemove");a.isRayEvent=!0;a.ray=b;a.eventSource=c;this._onPointerMotionEvent(a)},rayPointerAction:function(c,b){var a=new ("wheel"===b.type?WheelEvent:MouseEvent)(b.type,b);a.isRayEvent=!0;a.ray=b.ray;a.eventSource=c;this._onPointerActionEvent(a)}});var Sa="onMouseOver onMouseOut onMouseMove onMouseDown onMouseUp onClick onDoubleClick".split(" ");r=function(c){function b(a){var b=new e.Object3D;b.isRenderable=!1;b.$troikaVisible=b.visible;
Object.defineProperty(b,"visible",Ta);c.call(this,a,b);this.notifyWorld("instanceableAdded")}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={instancedThreeObject:{configurable:!0}};a.instancedThreeObject.set=function(a){a!==this._instancedThreeObject&&(this._instancedThreeObject=a,this.notifyWorld("instanceableChanged"),this._boundsChanged=!0)};a.instancedThreeObject.get=function(){return this._instancedThreeObject};b.prototype.setInstanceUniform=function(a,
b){var c=this._instanceUniforms||(this._instanceUniforms=Object.create(null));c[a]!==b&&(c[a]=b,this.notifyWorld("instanceableUniformChanged",a))};b.prototype.updateMatrices=function(){var a=this._worldMatrixVersion;c.prototype.updateMatrices.call(this);this._worldMatrixVersion!==a&&this.threeObject.$troikaVisible&&this.notifyWorld("instanceableMatrixChanged")};b.prototype.destructor=function(){this.notifyWorld("instanceableRemoved");c.prototype.destructor.call(this)};b.prototype.getGeometry=function(){var a=
this.instancedThreeObject;return a&&a.geometry};b.prototype.raycast=function(a){var b=this.instancedThreeObject,c=this.threeObject;if(b&&c){var d=b.matrixWorld;b.matrixWorld=c.matrixWorld;a=this._raycastObject(b,a);b.matrixWorld=d;return a}return null};Object.defineProperties(b.prototype,a);return b}(m);var Ta={set:function(c){c!==this.$troikaVisible&&(this.$troikaVisible=c,this.$facade.notifyWorld("instanceableChanged"))},get:function(){return this.$troikaVisible}};k.utils.assign(r.prototype,{_lastInstancedMatrixVersion:-1,
_instancedThreeObject:null});var P=new e.BufferGeometry,Ua=new e.MeshBasicMaterial,Q={basic:e.MeshBasicMaterial,depth:e.MeshDepthMaterial,distance:e.MeshDistanceMaterial,lambert:e.MeshLambertMaterial,matcap:e.MeshMatcapMaterial,normal:e.MeshNormalMaterial,phong:e.MeshPhongMaterial,physical:e.MeshPhysicalMaterial,standard:e.MeshStandardMaterial,toon:e.MeshToonMaterial},w=function(c){function b(a){c.call(this,a,new e.Mesh(P,Ua));this.material="standard";this.autoDisposeMaterial=this.autoDisposeGeometry=
!1;this._dirtyMtlProps=null}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.afterUpdate=function(){var a=this.geometry,b=this.material,g=this.threeObject;(a||P)!==g.geometry&&(this.autoDisposeGeometry&&g.geometry.dispose(),g.geometry=a||P);b!==this._lastMtl&&(this._lastMtl=b,"string"===typeof b?b=new (Q[b]||e.MeshStandardMaterial):b&&b.isMaterial||(b="function"===typeof b?new b:new e.MeshStandardMaterial),g.material!==b&&(this.autoDisposeMaterial&&
g.material.dispose(),g.material=b));if(a=this._dirtyMtlProps)g.material.setValues(a),this._dirtyMtlProps=null;c.prototype.afterUpdate.call(this)};b.prototype.destructor=function(){this.autoDisposeGeometry&&this.threeObject.geometry.dispose();this.autoDisposeMaterial&&this.threeObject.material.dispose();c.prototype.destructor.call(this)};return b}(m),Va={type:1,id:1,uuid:1,version:1};Object.keys(Q).forEach(function(c){var b=new Q[c];c=function(a){b.hasOwnProperty(a)&&!Va.hasOwnProperty(a)&&Object.defineProperty(w.prototype,
"material."+a,{enumerable:!0,configurable:!0,get:function(){var b=this._dirtyMtlProps;return b&&a in b?b[a]:this.threeObject.material[a]},set:function(b){(this._dirtyMtlProps||(this._dirtyMtlProps=Object.create(null)))[a]=b}})};for(var a in b)c(a)});var va=k.utils.memoize(function(){return new e.BoxBufferGeometry(1,1,1,1,1)}),Wa=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},
width:{configurable:!0},height:{configurable:!0},depth:{configurable:!0}};a.geometry.get=function(){return va()};a.width.set=function(a){this.scaleX=a};a.width.get=function(){return this.scaleX};a.height.set=function(a){this.scaleY=a};a.height.get=function(){return this.scaleY};a.depth.set=function(a){this.scaleZ=a};a.depth.get=function(){return this.scaleZ};Object.defineProperties(b.prototype,a);return b}(w),wa=Object.create(null,[["low",32],["medium",64],["high",128]].reduce(function(c,b){var a=
b[1];c[b[0]]={get:k.utils.memoize(function(){return(new e.CircleBufferGeometry(1,a)).rotateX(-Math.PI/2)})};return c},{})),Xa=function(c){function b(a){c.call(this,a);this["material.side"]=this["material.shadowSide"]=e.DoubleSide}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},radius:{configurable:!0}};a.geometry.get=function(){return wa[this.detail]||wa.medium};a.radius.set=function(a){this.scaleX=this.scaleZ=a};a.radius.get=
function(){return this.scaleX};Object.defineProperties(b.prototype,a);return b}(w),Ya=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},size:{configurable:!0}};a.geometry.get=function(){return va()};a.size.set=function(a){this.scale=a};a.size.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(w),Za=k.utils.memoize(function(){return(new e.PlaneBufferGeometry(1,
1,1,1)).rotateX(-Math.PI/2)}),$a=function(c){function b(a){c.call(this,a);this["material.side"]=this["material.shadowSide"]=e.DoubleSide}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},width:{configurable:!0},depth:{configurable:!0}};a.geometry.get=function(){return Za()};a.width.set=function(a){this.scaleX=a};a.width.get=function(){return this.scaleX};a.depth.set=function(a){this.scaleZ=a};a.depth.get=function(){return this.scaleZ};
Object.defineProperties(b.prototype,a);return b}(w),xa=Object.create(null,[["low",16,12],["medium",32,24],["high",64,48]].reduce(function(c,b){var a=b[1],d=b[2];c[b[0]]={get:k.utils.memoize(function(){return new e.SphereBufferGeometry(1,a,d)})};return c},{})),ab=function(c){function b(){c.apply(this,arguments)}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;var a={geometry:{configurable:!0},radius:{configurable:!0}};a.geometry.get=function(){return xa[this.detail]||
xa.medium};a.radius.set=function(a){this.scale=a};a.radius.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(w),I=function(c){function b(a){var b=this;c.call(this,a);this._onCanvasRef=function(a){var c=b.context.onCanvasRef;c&&c(a);(c=b.props.onCanvasRef)&&c(a)}}c&&(b.__proto__=c);b.prototype=Object.create(c&&c.prototype);b.prototype.constructor=b;b.prototype.render=function(){var a=this.props,b=this.context;return ha["default"].createElement(c,k.utils.assign({},a,
{onCanvasRef:this._onCanvasRef,canvasStyle:a.canvasStyle||b.canvasStyle,worldFacade:a.worldFacade||b.worldFacade||H,worldProps:k.utils.assign({antialias:a.antialias,rendererClass:a.rendererClass,backgroundColor:a.backgroundColor,background:a.background,environment:a.environment,outputEncoding:a.outputEncoding,toneMapping:a.toneMapping,shadows:a.shadows,camera:a.camera,lights:a.lights,objects:a.objects,fog:a.fog,onBackgroundClick:a.onBackgroundClick},b.worldProps,a.worldProps)}),a.children)};return b}(k.ReactCanvasBase);
I.displayName="Canvas3D";I.propTypes=k.utils.assignIf({backgroundColor:n["default"].any,background:n["default"].any,environment:n["default"].any,outputEncoding:n["default"].number,toneMapping:n["default"].number,lights:n["default"].array,camera:n["default"].object,objects:n["default"].oneOfType([n["default"].array,n["default"].object]).isRequired,antialias:n["default"].bool,onBackgroundClick:n["default"].func,rendererClass:n["default"].func},k.ReactCanvasBase.commonPropTypes);I.contextType=ha["default"].createContext({worldFacade:H,
worldProps:{},onCanvasRef:null,canvasStyle:null});Object.defineProperty(f,"Facade",{enumerable:!0,get:function(){return k.Facade}});Object.defineProperty(f,"ListFacade",{enumerable:!0,get:function(){return k.ListFacade}});Object.defineProperty(f,"ParentFacade",{enumerable:!0,get:function(){return k.ParentFacade}});Object.defineProperty(f,"createDerivedMaterial",{enumerable:!0,get:function(){return x.createDerivedMaterial}});f.AmbientLight3DFacade=ma;f.BoxFacade=Wa;f.Canvas3D=I;f.CircleFacade=Xa;f.CubeFacade=
Ya;f.DirectionalLight3DFacade=na;f.Group3DFacade=la;f.HemisphereLight3DFacade=qa;f.HtmlOverlay3DFacade=Ka;f.Instanceable3DFacade=r;f.InstancingManager=M;f.MeshFacade=w;f.Object3DFacade=m;f.OrthographicCamera3DFacade=A;f.PerspectiveCamera3DFacade=ka;f.PlaneFacade=$a;f.PointLight3DFacade=pa;f.RectAreaLight3DFacade=La;f.Scene3DFacade=ta;f.SphereFacade=ab;f.SpotLight3DFacade=oa;f.World3DFacade=H;f.makeWorldTextureProvider=function(c){return function(b){function a(a){var c=this,d=new e.CanvasTexture;b.call(this,
a,d);this.worldTexture=d;var f=this._refireAsInnerEvent.bind(this);Sa.forEach(function(a){function b(a){f(a);d&&d.call(this,a)}var d;c[a]=b;Object.defineProperty(c,a,{set:function(a){d=a},get:function(){return b}})})}b&&(a.__proto__=b);a.prototype=Object.create(b&&b.prototype);a.prototype.constructor=a;a.prototype.afterUpdate=function(){var a=this,c=this._worldFacade,e=this.textureWorld;c&&e&&c instanceof e.facade||(c&&(c.onAfterRender=null,c.destructor()),e&&(this.worldTexture.dispose(),c=document.createElement("canvas"),
c.width=c.height=2,this.worldTexture.image=c,c=this._worldFacade=new e.facade(c),c.onAfterRender=function(){a.worldTexture.needsUpdate=!0;a.notifyWorld("needsRender")}));c&&(c.renderingScheduler=this._getOuterWorld().renderingScheduler,k.utils.assign(c,e),c.afterUpdate());b.prototype.afterUpdate.call(this)};a.prototype._refireAsInnerEvent=function(a){var b=this._worldFacade;if(b){var c=a.intersection&&a.intersection.uv,d=c?Math.round(c.x*b.width):-1;b=c?Math.round((1-c.y)*b.height):-1;a=a.nativeEvent||
a;c=document.createEvent("MouseEvents");c.initMouseEvent(a.type,!0,!0,window,a.detail,d,b,d,b,a.ctrlKey,a.altKey,a.shiftKey,a.metaKey,a.button,null);this.worldTexture.image.dispatchEvent(c)}};a.prototype._getOuterWorld=function(){for(var a=this;a&&!a.isWorld;)a=a.parent;return a};a.prototype.destructor=function(){var a=this._worldFacade;a&&(a.onAfterRender=null,a.destructor());this.worldTexture.dispose();b.prototype.destructor.call(this)};return a}(c)};Object.defineProperty(f,"__esModule",{value:!0})})
{
"name": "troika-3d",
"version": "0.34.0",
"version": "0.34.2",
"description": "Troika 3D",

@@ -20,3 +20,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>",

},
"gitHead": "b19cd3aff4b0876253d76b3fc66b7e2a1f16a7e5"
"gitHead": "cbb2dab8b2fb5c39f06d88e342e3095218e5bee0"
}

@@ -89,23 +89,3 @@ import { PointerEventTarget, Facade, utils } from 'troika-core'

// object in a single batch; this avoids threejs's very expensive single-item remove.
if (this._removeChildIds) {
let threeObject = this.threeObject
let removeChildIds = this._removeChildIds
threeObject.children = threeObject.children.filter(child => {
if (child.id in removeChildIds) {
child.parent = null
child.dispatchEvent(removedEvent)
return false
}
return true
})
// If that resulted in a non-renderable object having no renderable children,
// queue it for removal it from the threejs object tree
let parentObj3D = this._parentObject3DFacade
if (canObjectBeOrphaned(threeObject) && parentObj3D && parentObj3D.threeObject === threeObject.parent) {
parentObj3D._queueRemoveChildObject3D(threeObject.id)
}
this._removeChildIds = null
}
this._flushQueuedChildRemovals()
}

@@ -390,2 +370,29 @@

_flushQueuedChildRemovals() {
// If any children were queued for removal, remove them from the threejs
// object in a single batch; this avoids threejs's very expensive single-item remove.
if (this._removeChildIds) {
let threeObject = this.threeObject
let removeChildIds = this._removeChildIds
threeObject.children = threeObject.children.filter(child => {
if (child.id in removeChildIds) {
child.parent = null
child.dispatchEvent(removedEvent)
return false
}
return true
})
// If that resulted in a non-renderable object having no renderable children,
// remove it from the threejs object tree, recursively upward.
let parentObj3D = this._parentObject3DFacade
if (canObjectBeOrphaned(threeObject) && parentObj3D && parentObj3D.threeObject === threeObject.parent) {
parentObj3D._queueRemoveChildObject3D(threeObject.id)
parentObj3D._flushQueuedChildRemovals() //if we don't force a parent flush, tree can get in a bad state
}
this._removeChildIds = null
}
}
destructor() {

@@ -392,0 +399,0 @@ this.notifyWorld('object3DRemoved')

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc