Comparing version 0.17.1 to 0.18.0
@@ -1,74 +0,82 @@ | ||
'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=f||self,e(f.troika_3d={},f.THREE,f.troika_core,f.troika_three_utils,f.React,f.PropTypes))})(this,function(f,e,l,v,y,q){function pa(c,b){return c.distance-b.distance}function O(c){return!1=== | ||
c.isRenderable&&(!c.children.length||c.children.every(O))}function P(c,b,a){function d(a,d){Object.defineProperty(g.prototype,a,{set:function(b){b!==this.threeObject[a]&&(this.threeObject[a]=b,d&&(this._projectionChanged=!0))},get:function(){return this.threeObject[a]}})}var g=function(a){function d(d){var b=new c;a.call(this,d,b);this.lookAt=this.up=null;this._projectionChanged=!1;this._frustum=new e.Frustum;b.updateMatrixWorld=qa}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor= | ||
d;d.prototype.afterUpdate=function(){this.lookAt&&(Q.copy(this.lookAt),R.copy(this.up||e.Object3D.DefaultUp),S.lookAt(this.threeObject.position,Q,R),C.setFromRotationMatrix(S),this.quaternionX=C.x,this.quaternionY=C.y,this.quaternionZ=C.z,this.quaternionW=C.w);a.prototype.afterUpdate.call(this)};d.prototype.updateMatrices=function(){var d=this.threeObject;this._projectionChanged&&(d.updateProjectionMatrix(),this._projectionChanged=!1,this._projectionMatrixVersion=ra++);var b=this._worldMatrixVersion; | ||
'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=f||self,e(f.troika_3d={},f.THREE,f.troika_core,f.troika_three_utils,f.React,f.PropTypes))})(this,function(f,e,l,t,w,p){function ua(c,b){return c.distance-b.distance}function Q(c){return!1=== | ||
c.isRenderable&&(!c.children.length||c.children.every(Q))}function R(c,b,a){function d(a,d){Object.defineProperty(g.prototype,a,{set:function(b){b!==this.threeObject[a]&&(this.threeObject[a]=b,d&&(this._projectionChanged=!0))},get:function(){return this.threeObject[a]}})}var g=function(a){function d(d){var b=new c;a.call(this,d,b);this.lookAt=this.up=null;this._projectionChanged=!1;this._frustum=new e.Frustum;b.updateMatrixWorld=va}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor= | ||
d;d.prototype.afterUpdate=function(){this.lookAt&&(S.copy(this.lookAt),T.copy(this.up||e.Object3D.DefaultUp),U.lookAt(this.threeObject.position,S,T),C.setFromRotationMatrix(U),this.quaternionX=C.x,this.quaternionY=C.y,this.quaternionZ=C.z,this.quaternionW=C.w);a.prototype.afterUpdate.call(this)};d.prototype.updateMatrices=function(){var d=this.threeObject;this._projectionChanged&&(d.updateProjectionMatrix(),this._projectionChanged=!1,this._projectionMatrixVersion=wa++);var b=this._worldMatrixVersion; | ||
a.prototype.updateMatrices.call(this);b!==this._worldMatrixVersion&&d.matrixWorldInverse.getInverse(d.matrixWorld)};d.prototype.getFrustum=function(){this.updateMatrices();var a=this._frustum,d=this._worldMatrixVersion,b=this._projectionMatrixVersion;if(a._lastWorldMatrixVersion!==d||a._lastProjMatrixVersion!==b){var c=this.threeObject;c=(new e.Matrix4).multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);a.setFromMatrix(c);a._lastWorldMatrixVersion=d;a._lastProjMatrixVersion=b}return a};d.prototype.getRayAtProjectedCoords= | ||
function(a,d){var b=T.ray=new e.Ray;T.setFromCamera(sa.set(a,d),this.threeObject);return b};return d}(p);b.forEach(function(a){d(a,!0)});a&&a.forEach(function(a){d(a,!1)});return g}function B(c,b,a){var d=function(a){function d(d){a.call(this,d,new c)}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor=d;var g={showHelper:{configurable:!0}};g.showHelper.set=function(a){var d=this._helper;!!a!==!!d&&(a?this.threeObject.add(this._helper=new b(this.threeObject)):d&&(d.dispose(), | ||
this.threeObject.remove(d),this._helper=null))};d.prototype.afterUpdate=function(){a.prototype.afterUpdate.call(this);this._helper&&this._helper.update()};Object.defineProperties(d.prototype,g);return d}(U);a&&Object.defineProperties(d.prototype,a);return d}function J(c,b,a){void 0===a&&(a=[]);c=v.expandShaderIncludes(c);b=v.expandShaderIncludes(b);var d=V.test(c),g=W.test(c),h=X.test(c),n=v.getShaderUniformTypes(c),e=v.getShaderUniformTypes(b),k=["\nattribute vec4 troika_modelMatrixRow0;\nattribute vec4 troika_modelMatrixRow1;\nattribute vec4 troika_modelMatrixRow2;\n"], | ||
r=[],f=[];if(d||g||h)c=c.replace(V,F),r.push(ta);if(g||h)c=c.replace(W,F),r.push("\nmat4 troika_modelViewMatrix = viewMatrix * troika_modelMatrix;\n");h&&(c=c.replace(X,F),r.push("\nmat3 troika_normalMatrix = transposeMat3(inverse(mat3(troika_modelViewMatrix)));\n"),/\binverse\s*\(/.test(c)||k.push("\n#if __VERSION__ < 300\n// matrix inversion utility for pre-ES3 - credit https://github.com/stackgl/glsl-inverse\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(\n b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)\n ) / det;\n}\n#endif\n")); | ||
a.forEach(function(a){var d=n[a],g=e[a];if(d||g){var h=new RegExp("\\b"+a+"\\b","g");k.push("attribute "+(d||g)+" troika_"+a+";");d&&(c=c.replace(h,F));g&&(b=b.replace(h,ua),d="varying "+g+" troika_vary_"+a+";",k.push(d),f.push(d),r.push("troika_vary_"+a+" = troika_"+a+";"))}});c=c.replace(v.voidMainRegExp,"\n"+k.join("\n")+"\n$&\n"+r.join("\n")+"\n");f.length&&(b=b.replace(v.voidMainRegExp,"\n"+f.join("\n")+"\n$&\n "));return{vertexShader:c,fragmentShader:b}}function Y(c,b,a){var d=c.itemSize; | ||
1===d?c.setX(b,a):2===d?c.setXY(b,a.x,a.y):3===d?a.isColor?c.setXYZ(b,a.r,a.g,a.b):c.setXYZ(b,a.x,a.y,a.z):4===d&&c.setXYZW(b,a.x,a.y,a.z,a.w)}y=y&&y.hasOwnProperty("default")?y["default"]:y;q=q&&q.hasOwnProperty("default")?q["default"]:q;var K=l.utils.assign,Z=l.utils.forOwn,aa=new e.Vector3,t=function(){var c={callback:function(b){c.value=b},value:null};return c}(),va={type:"removed"},D=[],wa=0,xa=0,p=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(va),!1):!0});var b=this._parentObject3DFacade;O(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=++wa;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){void 0===a&&(a=new e.Vector3);this.updateMatrices();a.setFromMatrixPosition(this.threeObject.matrixWorld);return a};b.prototype.getCameraPosition=function(){t.value=null;this.notifyWorld("getCameraPosition", | ||
t);return t.value};b.prototype.getCameraFacade=function(){t.value=null;this.notifyWorld("getCameraFacade",t);return t.value};b.prototype.getCameraDistance=function(){var a=this.getCameraPosition(),d=this.getWorldPosition(aa);return a.distanceTo(d)};b.prototype.getProjectedPosition=function(a,d,b){this.updateMatrices();t.value=null;t.worldPosition=aa.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=++xa);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(pa),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}(l.PointerEventTarget);["castShadow","receiveShadow","renderOrder","visible"].forEach(function(c){Object.defineProperty(p.prototype, | ||
c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});p.prototype.raycastSide=null;Z({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){Z(c,function(a,d){Object.defineProperty(p.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(p.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(p.prototype,"isObject3DFacade",{value:!0});K(p.prototype,{threeObject:null,_parentObject3DFacade:null,_removeChildIds:null,_matrixChanged:!0,_worldMatrixVersion:-1,_worldMatrixVersionAfterLastUpdate:-1,_boundingSphereChanged:!1});l.Facade.defineEventProperty(p,"onBeforeRender","beforerender");l.Facade.defineEventProperty(p,"onAfterRender","afterrender");var qa=function(){},T=new e.Raycaster,sa=new e.Vector2,Q=new e.Vector3,S=new e.Matrix4,C=new e.Quaternion,R=new e.Vector3(0, | ||
1,0),ra=0,ba=P(e.PerspectiveCamera,["fov","aspect","near","far"],["focus","filmGauge","filmOffset"]);K=P(e.OrthographicCamera,"left right top bottom near far".split(" "));var ca=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}(p),ya=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}(p),U=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){l.utils.assignDeep(this.threeObject.shadow,a)};Object.defineProperties(b.prototype,a);return b}(p);"intensity distance angle penumbra decay castShadow width height".split(" ").forEach(function(c){Object.defineProperty(U.prototype,c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});var da=B(e.AmbientLight),ea=B(e.DirectionalLight,e.DirectionalLightHelper),fa=B(e.SpotLight,e.SpotLightHelper), | ||
ha=B(e.PointLight,e.PointLightHelper),ia=B(e.HemisphereLight,e.HemisphereLightHelper,{groundColor:{set:function(c){this.threeObject.groundColor.set(c)},get:function(){return this.threeObject.groundColor.getHex()}}}),za=B(e.RectAreaLight),ta="\nmat4 troika_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"),V=/\bmodelMatrix\b/g,W=/\bmodelViewMatrix\b/g,X=/\bnormalMatrix\b/g,ja=/\buniform\s+(int|float|vec[234])\s+$/, | ||
F=function(c,b,a){return ja.test(a.substr(0,b))?c:"troika_"+c},ua=function(c,b,a){return ja.test(a.substr(0,b))?c:"troika_vary_"+c},z=l.utils.assign,Aa=l.utils.assignIf,L=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); | ||
function(a,d){var b=V.ray=new e.Ray;V.setFromCamera(xa.set(a,d),this.threeObject);return b};return d}(n);b.forEach(function(a){d(a,!0)});a&&a.forEach(function(a){d(a,!1)});return g}function z(c,b,a){var d=function(a){function d(d){a.call(this,d,new c)}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor=d;var g={showHelper:{configurable:!0}};g.showHelper.set=function(a){var d=this._helper;!!a!==!!d&&(a?this.threeObject.add(this._helper=new b(this.threeObject)):d&&(d.dispose(), | ||
this.threeObject.remove(d),this._helper=null))};d.prototype.afterUpdate=function(){a.prototype.afterUpdate.call(this);this._helper&&this._helper.update()};Object.defineProperties(d.prototype,g);return d}(W);a&&Object.defineProperties(d.prototype,a);return d}function K(c,b,a){void 0===a&&(a=[]);c=t.expandShaderIncludes(c);b=t.expandShaderIncludes(b);var d=X.test(c),g=Y.test(c),h=Z.test(c),u=t.getShaderUniformTypes(c),e=t.getShaderUniformTypes(b),k=["\nattribute vec4 troika_modelMatrixRow0;\nattribute vec4 troika_modelMatrixRow1;\nattribute vec4 troika_modelMatrixRow2;\n"], | ||
D=[],f=[];if(d||g||h)c=c.replace(X,G),D.push(ya);if(g||h)c=c.replace(Y,G),D.push("\nmat4 troika_modelViewMatrix = viewMatrix * troika_modelMatrix;\n");h&&(c=c.replace(Z,G),D.push("\nmat3 troika_normalMatrix = transposeMat3(inverse(mat3(troika_modelViewMatrix)));\n"),/\binverse\s*\(/.test(c)||k.push("\n#if __VERSION__ < 300\n// matrix inversion utility for pre-ES3 - credit https://github.com/stackgl/glsl-inverse\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(\n b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)\n ) / det;\n}\n#endif\n")); | ||
a.forEach(function(a){var d=u[a],g=e[a];if(d||g){var h=new RegExp("\\b"+a+"\\b","g");k.push("attribute "+(d||g)+" troika_"+a+";");d&&(c=c.replace(h,G));g&&(b=b.replace(h,za),d="varying "+g+" troika_vary_"+a+";",k.push(d),f.push(d),D.push("troika_vary_"+a+" = troika_"+a+";"))}});c=c.replace(t.voidMainRegExp,"\n"+k.join("\n")+"\n$&\n"+D.join("\n")+"\n");f.length&&(b=b.replace(t.voidMainRegExp,"\n"+f.join("\n")+"\n$&\n "));return{vertexShader:c,fragmentShader:b}}function aa(c,b,a){var d=c.itemSize; | ||
1===d?c.setX(b,a):2===d?c.setXY(b,a.x,a.y):3===d?a.isColor?c.setXYZ(b,a.r,a.g,a.b):c.setXYZ(b,a.x,a.y,a.z):4===d&&c.setXYZW(b,a.x,a.y,a.z,a.w)}w=w&&w.hasOwnProperty("default")?w["default"]:w;p=p&&p.hasOwnProperty("default")?p["default"]:p;var L=l.utils.assign,ba=l.utils.forOwn,ca=new e.Vector3,Aa=new e.Vector3,v=function(){var c={callback:function(b){c.value=b},value:null};return c}(),Ba={type:"removed"},E=[],Ca=0,Da=0,n=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(Ba),!1):!0});var b=this._parentObject3DFacade;Q(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= | ||
++Ca;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(){v.value=null;this.notifyWorld("getCameraFacade",v);return v.value};b.prototype.getCameraDistance=function(){var a=this.getCameraPosition(Aa),d=this.getWorldPosition(ca);return a.distanceTo(d)};b.prototype.getProjectedPosition=function(a,d,b){this.updateMatrices();v.value=null;v.worldPosition=ca.set(a||0,d||0,b||0).applyMatrix4(this.threeObject.matrixWorld);this.notifyWorld("projectWorldPosition",v);return v.value}; | ||
b.prototype.getSceneFacade=function(){v.value=null;this.notifyWorld("getSceneFacade",v);return v.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=++Da);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){E.length=0;var b=null,c=this.raycastSide;null!=c&&(b=a.material.side,a.material.side=c);a.raycast(d,E);null!==b&&(a.material.side=b);if(E.length)return E.sort(ua),E.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}(l.PointerEventTarget);["castShadow","receiveShadow","renderOrder","visible"].forEach(function(c){Object.defineProperty(n.prototype, | ||
c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});n.prototype.raycastSide=null;ba({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){ba(c,function(a,d){Object.defineProperty(n.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(n.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(n.prototype,"isObject3DFacade",{value:!0});L(n.prototype,{threeObject:null,_parentObject3DFacade:null,_removeChildIds:null,_matrixChanged:!0,_worldMatrixVersion:-1,_worldMatrixVersionAfterLastUpdate:-1,_boundingSphereChanged:!1});l.Facade.defineEventProperty(n,"onBeforeRender","beforerender");l.Facade.defineEventProperty(n,"onAfterRender","afterrender");var va=function(){},V=new e.Raycaster,xa=new e.Vector2,S=new e.Vector3,U=new e.Matrix4,C=new e.Quaternion,T=new e.Vector3(0, | ||
1,0),wa=0,da=R(e.PerspectiveCamera,["fov","aspect","near","far"],["focus","filmGauge","filmOffset"]);L=R(e.OrthographicCamera,"left right top bottom near far".split(" "));var ea=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}(n),Ea=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}(n),W=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){l.utils.assignDeep(this.threeObject.shadow,a)};Object.defineProperties(b.prototype,a);return b}(n);"intensity distance angle penumbra decay castShadow width height".split(" ").forEach(function(c){Object.defineProperty(W.prototype,c,{get:function(){return this.threeObject[c]},set:function(b){this.threeObject[c]=b}})});var fa=z(e.AmbientLight),ha=z(e.DirectionalLight,e.DirectionalLightHelper),ia=z(e.SpotLight,e.SpotLightHelper), | ||
ja=z(e.PointLight,e.PointLightHelper),ka=z(e.HemisphereLight,e.HemisphereLightHelper,{groundColor:{set:function(c){this.threeObject.groundColor.set(c)},get:function(){return this.threeObject.groundColor.getHex()}}}),Fa=z(e.RectAreaLight),ya="\nmat4 troika_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"),X=/\bmodelMatrix\b/g,Y=/\bmodelViewMatrix\b/g,Z=/\bnormalMatrix\b/g,la=/\buniform\s+(int|float|vec[234])\s+$/, | ||
G=function(c,b,a){return la.test(a.substr(0,b))?c:"troika_"+c},za=function(c,b,a){return la.test(a.substr(0,b))?c:"troika_vary_"+c},x=l.utils.assign,Ga=l.utils.assignIf,M=function(c){function b(a){c.call(this,a);this._instanceables=Object.create(null);this._batchGeometryPool=new H;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 k=c.threeObject, | ||
r=c.instancedThreeObject;if(r&&k.visible){var f=this._getBatchKey(r),l=r.material.instanceUniforms,x=a[f]||(a[f]=[]),p=(f=x[x.length-1])&&f.geometry;if(!p||1024===p.maxInstancedCount){f=this._getBatchObject(r);p=f.geometry;for(var q=p._instanceAttrs.matrix,m=0;3>m;m++)q[m].version++;if(l)for(q=p._instanceAttrs.uniforms,m=l.length;m--;)q[l[m]].version++;x.push(f)}x=p.maxInstancedCount++;q=p._instanceAttrs.matrix;k=k.matrixWorld.elements;q[0].setXYZW(x,k[0],k[4],k[8],k[12]);q[1].setXYZW(x,k[1],k[5], | ||
k[9],k[13]);q[2].setXYZW(x,k[2],k[6],k[10],k[14]);if(l)for(q=p._instanceAttrs.uniforms,k=l.length;k--;){m=l[k];p=q[m];var t=c._instanceUniforms;m=t&&m in t?t[m]:v.getShadersForMaterial(r.material).uniforms[m].value;Y(p,x,m)}c._instancingBatchObject=f;c._instancingBatchAttrOffset=x}else c._instancingBatchObject=c._instancingBatchAttrOffset=null}g.disposeUnused()}g=b=e=0;for(var u in a)for(c=a[u],d.children.push.apply(d.children,c),b++,r=c.length;r--;)e++,g+=c[r].geometry.maxInstancedCount;this.notifyWorld("statsUpdate", | ||
f=c.instancedThreeObject;if(f&&k.visible){var l=this._getBatchKey(f),A=f.material.instanceUniforms,n=a[l]||(a[l]=[]),p=(l=n[n.length-1])&&l.geometry;if(!p||1024===p.maxInstancedCount){l=this._getBatchObject(f);p=l.geometry;for(var q=p._instanceAttrs.matrix,m=0;3>m;m++)q[m].version++;if(A)for(q=p._instanceAttrs.uniforms,m=A.length;m--;)q[A[m]].version++;n.push(l)}n=p.maxInstancedCount++;q=p._instanceAttrs.matrix;k=k.matrixWorld.elements;q[0].setXYZW(n,k[0],k[4],k[8],k[12]);q[1].setXYZW(n,k[1],k[5], | ||
k[9],k[13]);q[2].setXYZW(n,k[2],k[6],k[10],k[14]);if(A)for(q=p._instanceAttrs.uniforms,k=A.length;k--;){m=A[k];p=q[m];var r=c._instanceUniforms;m=r&&m in r?r[m]:t.getShadersForMaterial(f.material).uniforms[m].value;aa(p,n,m)}c._instancingBatchObject=l;c._instancingBatchAttrOffset=n}else c._instancingBatchObject=c._instancingBatchAttrOffset=null}g.disposeUnused()}g=b=e=0;for(var v in a)for(c=a[v],d.children.push.apply(d.children,c),b++,f=c.length;f--;)e++,g+=c[f].geometry.maxInstancedCount;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,d){if(!this._needsRebatch){var b=a.instancedThreeObject,c=a._instancingBatchObject; | ||
b&&c&&this._getBatchKey(b)===this._getBatchKey(c)?(b=c.geometry._instanceAttrs.uniforms[d],Y(b,a._instancingBatchAttrOffset,a._instanceUniforms[d]),b.version++):(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._getBatchKey=function(a){var d=this._batchKeysCache||(this._batchKeysCache=Object.create(null)),b=d&&d[a.id];if(!b){b=a.material;var c=v.getShadersForMaterial(b),n=b.instanceUniforms;b=a.geometry.id+"|"+b.id+"|"+c.vertexShader+"|"+c.fragmentShader+ | ||
"|"+(n?n.sort().join(","):"");d[a.id]=b}return b};b.prototype._getInstanceUniformsTypes=function(a){var d=this._uniformTypesCache||(this._uniformTypesCache=Object.create(null)),b=d[a.id];if(!b&&(b=d[a.id]=Object.create(null),(d=a.instanceUniforms)&&d.length)){a=v.getShadersForMaterial(a);var c=a.fragmentShader;a=z(v.getShaderUniformTypes(v.expandShaderIncludes(a.vertexShader)),v.getShaderUniformTypes(v.expandShaderIncludes(c)));for(c=d.length;c--;){var n=d[c];a[n]&&(b[n]=a[n])}}return b};b.prototype._getBatchObject= | ||
function(a){var d,b=a.geometry,c=a.material;if(!b.isBufferGeometry)throw Error("Instanceable proto object must use a BufferGeometry");var n=this._getBatchKey(a),f=this._getInstanceUniformsTypes(c);b=this._batchGeometryPool.borrow(n,b,f);b.maxInstancedCount=0;n=Object.create(c);var k=c.instanceUniforms||[];k.sort();n.defines=Aa((d={},d["TROIKA_INSTANCED_"+k.join("_")]="",d),n.defines);n.onBeforeCompile=function(a){var b=c.$troikaUpgraded,d=a.vertexShader+"|"+a.fragmentShader+"|"+k.join(",");b&&b.upgradeKey=== | ||
d||(b=c.$troikaUpgraded=J(a.vertexShader,a.fragmentShader,k),b.upgradeKey=d);z(a,b)};var r=null;d=Object.create(a,{customDepthMaterial:{get:function(){return r=ka()}},customDistanceMaterial:{get:function(){return r=la()}},modelViewMatrix:{value:function(){var a=new e.Matrix4;a.multiplyMatrices=function(a,b){e.Matrix4.prototype.multiplyMatrices.call(this,a,b);r&&r._updateViewMatrix&&r._updateViewMatrix(a)};return a}()}});d.$troikaBatchBaseObj=a;d.$troikaInstancingManager=this;d.visible=!0;d.frustumCulled= | ||
!1;d.geometry=b;d.material=n;return d};b.prototype._teardownBatchObjects=function(a,b,c){var d=this;this._batchGeometryPool.releaseAll();this._uniformTypesCache=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}(ca),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;z(d,b);d.attributes=z({},b.attributes);b=d._instanceAttrs={matrix:[],uniforms:Object.create(null)};for(var g=0;3>g;g++){var h=new e.InstancedBufferAttribute(new Float32Array(4096),4);h.setUsage?h.setUsage(35048):h.dynamic=!0;d.attributes["troika_modelMatrixRow"+g]=h;b.matrix[g]=h}for(var n in a)g=a[n],h=Ba[g],g=new e.InstancedBufferAttribute(new ("int"===g?Uint32Array:Float32Array)(1024* | ||
h),h),g.setUsage?g.setUsage(35048):g.dynamic=!0,d.attributes["troika_"+n]=g,b.uniforms[n]=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,h=a.length;g<h;g++){var n=a[g].attributes,e;for(e in n)n.hasOwnProperty(e)&&0!==e.indexOf("troika_")&&delete n[e];try{a[g].dispose()}catch(k){}a[g]._instanceAttrs= | ||
null}a.length=d}};var w=L.prototype;w._notifyWorldHandlers={instanceableAdded:w._onInstanceAdded,instanceableRemoved:w._onInstanceRemoved,instanceableChanged:w._onInstanceChanged,instanceableMatrixChanged:w._onInstanceMatrixChanged,instanceableUniformChanged:w._onInstanceUniformChanged};var Ba={"int":1,"float":1,vec2:2,vec3:3,vec4:4},ka=function(){var c=z({},e.ShaderLib.depth);c.vertexShader=J(c.vertexShader,"",[]).vertexShader;var b=new e.ShaderMaterial(c);b.isMeshDepthMaterial=!0;b.depthPacking= | ||
e.RGBADepthPacking;ka=function(){return b};return b},la=function(){var c=z({},e.ShaderLib.distanceRGBA),b=new e.Matrix4;c.vertexShader=J(c.vertexShader,"",[]).vertexShader;c.uniforms=z({viewMatrix:{value:b}},c.uniforms);var a=new e.ShaderMaterial(c);a.isMeshDistanceMaterial=!0;a.referencePosition=new e.Vector3;a._updateViewMatrix=function(d){b.copy(d);a.uniformsNeedUpdate=!0};la=function(){return a};return a},Ca={ambient:da,directional:ea,spot:fa,point:ha,hemisphere:ia},Da=[{distance:Infinity}],Ea= | ||
new e.Sphere(void 0,Infinity),ma=[null],na=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.describeChildren=function(){var a={key:"instancingMgr",facade:L,children:this.objects},b=this.lights;b&&(a=[a],Array.isArray(b)||(ma[0]=b,b=ma),b.forEach(function(b,d){var c=b.facade||Ca[b.type];if("function"===typeof c){var g=l.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 d="density"in a,c=d?e.FogExp2:e.Fog;b&&b instanceof c||(b=this._fogObj=new c);b.color.set(a.color);d?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 Ea};b.prototype.raycast=function(a){return Da};Object.defineProperties(b.prototype,a);return b}(p);w=l.utils.assign;var Fa=l.utils.forOwn,M=new e.Sphere, | ||
Ga=Math.sqrt(3),u=function(){this.root=null;this.keysToLeaves=Object.create(null)};u.prototype.putSpheres=function(c){var b=this;Fa(c,function(a,d){b.putSphere(d,a)})};u.prototype.putSphere=function(c,b){var a=this,d=b.center,g=b.radius,h=this.root;if(!b||isNaN(g)||isNaN(d.x))console.warn("Invalid sphere",b);else{if(c in this.keysToLeaves)return this._updateSphere(c,b);if(h)if(h.isLeaf){g=this.root;var n=h.dataX,e=h.dataY,k=h.dataZ;if(n===d.x&&e===d.y&&k===d.z)this._insertIntoOctant(c,b,h);else{var f= | ||
new m;h=f.cx=Math.round((n+d.x)/2);var l=f.cy=Math.round((e+d.y)/2);d=f.cz=Math.round((k+d.z)/2);f.cr=Math.ceil(Math.max(Math.abs(h-n),Math.abs(l-e),Math.abs(d-k))+1E-5);this.root=f;g.forEachLeafSphere(function(b,d){return a._insertIntoOctant(d,b,f)});this._insertIntoOctant(c,b,f)}}else this._expandToCoverPoint(d.x,d.y,d.z),this._insertIntoOctant(c,b,this.root);else d=new m,d.isLeaf=!0,d.addSphereData(c,b),this.root=d,this.keysToLeaves[c]=d}};u.prototype._expandToCoverPoint=function(c,b,a){for(;!this.root.containsPoint(c, | ||
b,a);){var d=this.root,g=d.cx,h=d.cy,e=d.cz,f=d.cr,k=new m;k.maxRadius=d.maxRadius;k.sphereCount=d.sphereCount;k.leafCount=d.leafCount;k.cx=g+f*(c<g?-1:1);k.cy=h+f*(b<h?-1:1);k.cz=e+f*(a<e?-1:1);k.cr=2*f;g=k.getSubOctantIndexForPoint(g,h,e);d.parent=k;d.index=g;k[g]=d;this.root=k}};u.prototype._insertIntoOctant=function(c,b,a){var d=b.center,g=b.radius;if(a.isLeaf){var h=a.dataX,e=a.dataY,f=a.dataZ;if(d.x===h&&d.y===e&&d.z===f){a.addSphereData(c,b);for(b=a.parent;b;b=b.parent)g>b.maxRadius&&(b.maxRadius= | ||
g);this.keysToLeaves[c]=a}else g=Ha(a),a.parent[a.index]=g,g.addOctantForPoint(a,h,e,f),this._insertIntoOctant(c,b,g)}else{a.sphereCount++;h=a.getSubOctantIndexForPoint(d.x,d.y,d.z);if(h=a[h])return this._insertIntoOctant(c,b,h);h=new m;h.isLeaf=!0;a.addOctantForPoint(h,d.x,d.y,d.z);h.addSphereData(c,b);for(a=h.parent;a;a=a.parent)g>a.maxRadius&&(a.maxRadius=g),a.leafCount++;this.keysToLeaves[c]=h}};u.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]}};u.prototype._updateSphere=function(c,b){var a=this.keysToLeaves[c],d=b.center;if(a.containsPoint(d.x, | ||
d.y,d.z)){var g=d.x!==a.dataX||d.y!==a.dataY||d.z!==a.dataZ;1<a.sphereCount&&g?(a.removeSphereData(c),a.updateMaxRadii(),this._insertIntoOctant(c,b,a)):(g&&(a.dataX=d.x,a.dataY=d.y,a.dataZ=d.z),b.radius!==a.maxRadius&&a.updateMaxRadii())}else this.removeSphere(c),this.putSphere(c,b)};u.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)};u.prototype.walkTree=function(c){this.root&& | ||
this.walkBranch(this.root,c)};u.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)};u.prototype.forEachSphereOnRay=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};u.prototype.forEachIntersectingSphere=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};u.prototype._forEachMatchingSphere=function(c,b,a){function d(d,h){c(d)&&b.call(a,d,h)}this.walkTree(function(a){if(a.isLeaf)a.forEachLeafSphere(d); | ||
else if(M.center.set(a.cx,a.cy,a.cz),M.radius=a.cr*Ga+a.maxRadius,!c(M))return!1;return!0})};var m=function(){};m.prototype.containsPoint=function(c,b,a){var d=this.cx,g=this.cy,h=this.cz,e=this.cr;return c>=d-e&&c<d+e&&b>=g-e&&b<g+e&&a>=h-e&&a<h+e};m.prototype.getSubOctantIndexForPoint=function(c,b,a){return(a<this.cz?0:4)+(b<this.cy?0:2)+(c<this.cx?0:1)};m.prototype.addOctantForPoint=function(c,b,a,d){var g=this.getSubOctantIndexForPoint(b,a,d),h=this.cr/2;c.parent=this;c.index=g;c.cx=this.cx+h* | ||
(b<this.cx?-1:1);c.cy=this.cy+h*(a<this.cy?-1:1);c.cz=this.cz+h*(d<this.cz?-1:1);c.cr=h;return this[g]=c};m.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};m.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())};m.prototype.addSphereData=function(c,b){var a=this.sphereCount++;if(0===a)this.leafCount=1,this.data=b,this.dataKey=c,c=b.center,this.dataX=c.x,this.dataY=c.y,this.dataZ=c.z;else if(1===a){a=this.data;var d=this.data=Object.create(null);d[this.dataKey]=a;d[c]=b;this.dataKey=null}else 1<a&&(this.data[c]=b);b.radius>this.maxRadius&&(this.maxRadius=b.radius)};m.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}};m.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)};w(m.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 Ha=function(){var c="parent index cx cy cz cr sphereCount leafCount maxRadius".split(" ");return function(b){for(var a=new m,d=c.length;d--;)a[c[d]]=b[c[d]];return a}}(),E=l.utils.assign,N=new e.Vector2,A=new e.Vector3,oa=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,h=this.backgroundColor,f=this.contextAttributes,l=this._element,k=this._threeRenderer,r=this.rendererClass||e.WebGLRenderer;k&&k instanceof r||(k&&k.dispose(),f=E({alpha:!0,antialias:g},f),(k=l.getContext("webgl2",f)||void 0)||console.info("webgl2 init failed, trying webgl"),k=this._threeRenderer=new r(E({canvas:l,context:k},f)));f=this.shadows;k.shadowMap.enabled=!!f;f&&"object"===typeof f&&E(k.shadowMap,f);h!==this._bgColor&&(this._threeRenderer.setClearColor(new e.Color(h|| | ||
0),null!=h?1:0),this._bgColor=h);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:ba,aspect:this.width/this.height},this.camera)};b.prototype._getSceneDef=function(){return{key:"scene",facade:na,lights:this.lights,objects:this.objects,fog:this.fog,onClick:this.onBackgroundClick? | ||
this._onBgClick:null}};b.prototype._updateDrawingBufferSize=function(a,b,c){var d=this._threeRenderer;d.getSize(N);N.width===a&&N.height===b&&d.getPixelRatio()===c||d.setDrawingBufferSize(a,b,c)};b.prototype.doRender=function(){function a(a,d){a.call(this._object3DFacadesById[d],h,b,c)}var b=this.getChildByKey("scene").threeObject,c=this.getChildByKey("camera").threeObject,h=this._threeRenderer,e=this.eventRegistry;e.forEachListenerOfType("beforerender",a,this);h.render(b,c);e.forEachListenerOfType("afterrender", | ||
a,this);if(e=this.onStatsUpdate){var f=h.info,k=f.memory;f=f.render;k={"WebGL Draw Calls":f.calls,"WebGL Geometries":k.geometries,"WebGL Textures":k.textures,"WebGL Triangles":f.triangles};f.points&&(k["WebGL Points"]=f.points);f.lines&&(k["WebGL Lines"]=f.lines);e(k)}};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){A.set(a,b,c);a=this.getChildByKey("camera");a.updateMatrices(); | ||
a=a.threeObject;A.applyMatrix4(a.matrixWorldInverse);b=A.length()*(0<A.z?-1:1);A.applyMatrix4(a.projectionMatrix);return new e.Vector3((A.x+1)*this.width/2,(1-A.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 h=a.target.getBoundingClientRect();g=((b.clientX||0)-(h.left||0))/(h.width||this.width)*2-1;b=((b.clientY||0)-(h.top||0))/(h.height||this.height)* | ||
-2+1;h=this.getChildByKey("camera");h.updateMatrices();a.ray=h.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 d=this,c=this._updateOctree(),e=null;c&&(oa.ray=a,c.forEachSphereOnRay(a,function(a,c){(a=(c=(a=d._object3DFacadesById)&&a[c])&&(!b||b(c))&&c.raycast&&c.raycast(oa))&&a[0]&&(a[0].facade=c,(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 u);var c=b.remove;b=b.put;if(c)for(var h in c)a.removeSphere(h);if(b)for(var e in b)h=this._object3DFacadesById[e],!h||h.isDestroying||c&&c[e]||((h=h.getBoundingSphere&&h.getBoundingSphere())?a.putSphere(e,h):a.removeSphere(e));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();this._threeRenderer.forceContextLoss()};return b}(l.WorldBaseFacade);H.prototype._notifyWorldHandlers=E(Object.create(l.WorldBaseFacade.prototype._notifyWorldHandlers),{getCameraPosition:function(c,b){c=this.getChildByKey("camera").threeObject.matrixWorld.elements; | ||
c=new e.Vector3(c[12],c[13],c[14]);b.callback(c)},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 Ia="onMouseOver onMouseOut onMouseMove onMouseDown onMouseUp onClick onDoubleClick".split(" ");w=function(c){function b(a){var b=new e.Object3D;b.isRenderable= | ||
!1;b.$troikaVisible=b.visible;Object.defineProperty(b,"visible",Ja);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}(p);var Ja={set:function(c){c!==this.$troikaVisible&&(this.$troikaVisible=c,this.$facade.notifyWorld("instanceableChanged"))},get:function(){return this.$troikaVisible}};l.utils.assign(w.prototype, | ||
{_lastInstancedMatrixVersion:-1,_instancedThreeObject:null});var 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 y.createElement(c,l.utils.assign({},a,{onCanvasRef:this._onCanvasRef,canvasStyle:a.canvasStyle||b.canvasStyle,worldFacade:a.worldFacade|| | ||
b.worldFacade||H,worldProps:l.utils.assign({antialias:a.antialias,rendererClass:a.rendererClass,backgroundColor:a.backgroundColor,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}(l.ReactCanvasBase);I.displayName="Canvas3D";I.propTypes=l.utils.assignIf({backgroundColor:q.any,lights:q.array,camera:q.object,objects:q.oneOfType([q.array,q.object]).isRequired,antialias:q.bool,onBackgroundClick:q.func, | ||
rendererClass:q.func},l.ReactCanvasBase.commonPropTypes);I.contextType=y.createContext({worldFacade:H,worldProps:{},onCanvasRef:null,canvasStyle:null});Object.defineProperty(f,"Facade",{enumerable:!0,get:function(){return l.Facade}});Object.defineProperty(f,"ListFacade",{enumerable:!0,get:function(){return l.ListFacade}});Object.defineProperty(f,"ParentFacade",{enumerable:!0,get:function(){return l.ParentFacade}});Object.defineProperty(f,"createDerivedMaterial",{enumerable:!0,get:function(){return v.createDerivedMaterial}}); | ||
f.AmbientLight3DFacade=da;f.Canvas3D=I;f.DirectionalLight3DFacade=ea;f.Group3DFacade=ca;f.HemisphereLight3DFacade=ia;f.HtmlOverlay3DFacade=ya;f.Instanceable3DFacade=w;f.InstancingManager=L;f.Object3DFacade=p;f.OrthographicCamera3DFacade=K;f.PerspectiveCamera3DFacade=ba;f.PointLight3DFacade=ha;f.RectAreaLight3DFacade=za;f.Scene3DFacade=na;f.SpotLight3DFacade=fa;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);Ia.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,l.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&&c&&this._getBatchKey(b)===this._getBatchKey(c)?(b=c.geometry._instanceAttrs.uniforms[d],aa(b,a._instancingBatchAttrOffset,a._instanceUniforms[d]),b.version++):(a._instancingBatchObject=a._instancingBatchAttrOffset=null,this._needsRebatch=!0)}};b.prototype._getBatchKey=function(a){var d=this._batchKeysCache||(this._batchKeysCache=Object.create(null)),b=d&&d[a.id];if(!b){b=a.material;var c=t.getShadersForMaterial(b),e=b.instanceUniforms;b=a.geometry.id+"|"+b.id+"|"+c.vertexShader+"|"+c.fragmentShader+ | ||
"|"+(e?e.sort().join(","):"");d[a.id]=b}return b};b.prototype._getInstanceUniformsTypes=function(a){var b=this._uniformTypesCache||(this._uniformTypesCache=Object.create(null)),c=b[a.id];if(!c&&(c=b[a.id]=Object.create(null),(b=a.instanceUniforms)&&b.length)){a=t.getShadersForMaterial(a);var h=a.fragmentShader;a=x(t.getShaderUniformTypes(t.expandShaderIncludes(a.vertexShader)),t.getShaderUniformTypes(t.expandShaderIncludes(h)));for(h=b.length;h--;){var e=b[h];a[e]&&(c[e]=a[e])}}return c};b.prototype._getBatchObject= | ||
function(a){var b,c=a.geometry,h=a.material;if(!c.isBufferGeometry)throw Error("Instanceable proto object must use a BufferGeometry");var u=this._getBatchKey(a),f=this._getInstanceUniformsTypes(h);c=this._batchGeometryPool.borrow(u,c,f);c.maxInstancedCount=0;u=Object.create(h);var k=h.instanceUniforms||[];k.sort();u.defines=Ga((b={},b["TROIKA_INSTANCED_"+k.join("_")]="",b),u.defines);u.onBeforeCompile=function(a){var b=h.$troikaUpgraded,d=a.vertexShader+"|"+a.fragmentShader+"|"+k.join(",");b&&b.upgradeKey=== | ||
d||(b=h.$troikaUpgraded=K(a.vertexShader,a.fragmentShader,k),b.upgradeKey=d);x(a,b)};var l=null;b=Object.create(a,{customDepthMaterial:{get:function(){return l=ma()}},customDistanceMaterial:{get:function(){return l=na()}},modelViewMatrix:{value:function(){var a=new e.Matrix4;a.multiplyMatrices=function(a,b){e.Matrix4.prototype.multiplyMatrices.call(this,a,b);l&&l._updateViewMatrix&&l._updateViewMatrix(a)};return a}()}});b.$troikaBatchBaseObj=a;b.$troikaInstancingManager=this;b.visible=!0;b.frustumCulled= | ||
!1;b.geometry=c;b.material=u;return b};b.prototype._teardownBatchObjects=function(a,b,c){var d=this;this._batchGeometryPool.releaseAll();this._uniformTypesCache=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}(ea),H=function(){this._poolsByKey=Object.create(null)};H.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;x(d,b);d.attributes=x({},b.attributes);b=d._instanceAttrs={matrix:[],uniforms:Object.create(null)};for(var g=0;3>g;g++){var h=new e.InstancedBufferAttribute(new Float32Array(4096),4);h.setUsage?h.setUsage(35048):h.dynamic=!0;d.attributes["troika_modelMatrixRow"+g]=h;b.matrix[g]=h}for(var u in a)g=a[u],h=Ha[g],g=new e.InstancedBufferAttribute(new ("int"===g?Uint32Array:Float32Array)(1024* | ||
h),h),g.setUsage?g.setUsage(35048):g.dynamic=!0,d.attributes["troika_"+u]=g,b.uniforms[u]=g;c.geometries.push(d)}return d};H.prototype.releaseAll=function(){var c=this._poolsByKey;if(c)for(var b in c)c[b].firstFree=0};H.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,h=a.length;g<h;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(k){}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 Ha={"int":1,"float":1,vec2:2,vec3:3,vec4:4},ma=function(){var c=x({},e.ShaderLib.depth);c.vertexShader=K(c.vertexShader,"",[]).vertexShader;var b=new e.ShaderMaterial(c);b.isMeshDepthMaterial=!0;b.depthPacking= | ||
e.RGBADepthPacking;ma=function(){return b};return b},na=function(){var c=x({},e.ShaderLib.distanceRGBA),b=new e.Matrix4;c.vertexShader=K(c.vertexShader,"",[]).vertexShader;c.uniforms=x({viewMatrix:{value:b}},c.uniforms);var a=new e.ShaderMaterial(c);a.isMeshDistanceMaterial=!0;a.referencePosition=new e.Vector3;a._updateViewMatrix=function(d){b.copy(d);a.uniformsNeedUpdate=!0};na=function(){return a};return a},Ia={ambient:fa,directional:ha,spot:ia,point:ja,hemisphere:ka},Ja=[{distance:Infinity}],Ka= | ||
new e.Sphere(void 0,Infinity),oa=[null],pa=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.describeChildren=function(){var a={key:"instancingMgr",facade:M,children:this.objects},b=this.lights;b&&(a=[a],Array.isArray(b)||(oa[0]=b,b=oa),b.forEach(function(b,d){var c=b.facade||Ia[b.type];if("function"===typeof c){var g=l.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 d="density"in a,c=d?e.FogExp2:e.Fog;b&&b instanceof c||(b=this._fogObj=new c);b.color.set(a.color);d?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 Ka};b.prototype.raycast=function(a){return Ja};Object.defineProperties(b.prototype,a);return b}(n);r=l.utils.assign;var La=l.utils.forOwn,N=new e.Sphere, | ||
Ma=Math.sqrt(3),m=function(){this.root=null;this.keysToLeaves=Object.create(null)};m.prototype.putSpheres=function(c){var b=this;La(c,function(a,c){b.putSphere(c,a)})};m.prototype.putSphere=function(c,b){var a=this,d=b.center,g=b.radius,h=this.root;if(!b||isNaN(g)||isNaN(d.x))console.warn("Invalid sphere",b);else{if(c in this.keysToLeaves)return this._updateSphere(c,b);if(h)if(h.isLeaf){g=this.root;var e=h.dataX,f=h.dataY,k=h.dataZ;if(e===d.x&&f===d.y&&k===d.z)this._insertIntoOctant(c,b,h);else{var l= | ||
new q;h=l.cx=Math.round((e+d.x)/2);var m=l.cy=Math.round((f+d.y)/2);d=l.cz=Math.round((k+d.z)/2);l.cr=Math.ceil(Math.max(Math.abs(h-e),Math.abs(m-f),Math.abs(d-k))+1E-5);this.root=l;g.forEachLeafSphere(function(b,c){return a._insertIntoOctant(c,b,l)});this._insertIntoOctant(c,b,l)}}else this._expandToCoverPoint(d.x,d.y,d.z),this._insertIntoOctant(c,b,this.root);else d=new q,d.isLeaf=!0,d.addSphereData(c,b),this.root=d,this.keysToLeaves[c]=d}};m.prototype._expandToCoverPoint=function(c,b,a){for(;!this.root.containsPoint(c, | ||
b,a);){var d=this.root,g=d.cx,h=d.cy,e=d.cz,f=d.cr,k=new q;k.maxRadius=d.maxRadius;k.sphereCount=d.sphereCount;k.leafCount=d.leafCount;k.cx=g+f*(c<g?-1:1);k.cy=h+f*(b<h?-1:1);k.cz=e+f*(a<e?-1:1);k.cr=2*f;g=k.getSubOctantIndexForPoint(g,h,e);d.parent=k;d.index=g;k[g]=d;this.root=k}};m.prototype._insertIntoOctant=function(c,b,a){var d=b.center,g=b.radius;if(a.isLeaf){var h=a.dataX,e=a.dataY,f=a.dataZ;if(d.x===h&&d.y===e&&d.z===f){a.addSphereData(c,b);for(b=a.parent;b;b=b.parent)g>b.maxRadius&&(b.maxRadius= | ||
g);this.keysToLeaves[c]=a}else g=Na(a),a.parent[a.index]=g,g.addOctantForPoint(a,h,e,f),this._insertIntoOctant(c,b,g)}else{a.sphereCount++;h=a.getSubOctantIndexForPoint(d.x,d.y,d.z);if(h=a[h])return this._insertIntoOctant(c,b,h);h=new q;h.isLeaf=!0;a.addOctantForPoint(h,d.x,d.y,d.z);h.addSphereData(c,b);for(a=h.parent;a;a=a.parent)g>a.maxRadius&&(a.maxRadius=g),a.leafCount++;this.keysToLeaves[c]=h}};m.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]}};m.prototype._updateSphere=function(c,b){var a=this.keysToLeaves[c],d=b.center;if(a.containsPoint(d.x, | ||
d.y,d.z)){var g=d.x!==a.dataX||d.y!==a.dataY||d.z!==a.dataZ;1<a.sphereCount&&g?(a.removeSphereData(c),a.updateMaxRadii(),this._insertIntoOctant(c,b,a)):(g&&(a.dataX=d.x,a.dataY=d.y,a.dataZ=d.z),b.radius!==a.maxRadius&&a.updateMaxRadii())}else this.removeSphere(c),this.putSphere(c,b)};m.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)};m.prototype.walkTree=function(c){this.root&& | ||
this.walkBranch(this.root,c)};m.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)};m.prototype.forEachSphereOnRay=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};m.prototype.forEachIntersectingSphere=function(c,b,a){return this._forEachMatchingSphere(c.intersectsSphere.bind(c),b,a)};m.prototype._forEachMatchingSphere=function(c,b,a){function d(d,h){c(d)&&b.call(a,d,h)}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*Ma+a.maxRadius,!c(N))return!1;return!0})};var q=function(){};q.prototype.containsPoint=function(c,b,a){var d=this.cx,g=this.cy,h=this.cz,e=this.cr;return c>=d-e&&c<d+e&&b>=g-e&&b<g+e&&a>=h-e&&a<h+e};q.prototype.getSubOctantIndexForPoint=function(c,b,a){return(a<this.cz?0:4)+(b<this.cy?0:2)+(c<this.cx?0:1)};q.prototype.addOctantForPoint=function(c,b,a,d){var g=this.getSubOctantIndexForPoint(b,a,d),h=this.cr/2;c.parent=this;c.index=g;c.cx=this.cx+h* | ||
(b<this.cx?-1:1);c.cy=this.cy+h*(a<this.cy?-1:1);c.cz=this.cz+h*(d<this.cz?-1:1);c.cr=h;return this[g]=c};q.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};q.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())};q.prototype.addSphereData=function(c,b){var a=this.sphereCount++;if(0===a)this.leafCount=1,this.data=b,this.dataKey=c,c=b.center,this.dataX=c.x,this.dataY=c.y,this.dataZ=c.z;else if(1===a){a=this.data;var d=this.data=Object.create(null);d[this.dataKey]=a;d[c]=b;this.dataKey=null}else 1<a&&(this.data[c]=b);b.radius>this.maxRadius&&(this.maxRadius=b.radius)};q.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}};q.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(q.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 Na=function(){var c="parent index cx cy cz cr sphereCount leafCount maxRadius".split(" ");return function(b){for(var a=new q,d=c.length;d--;)a[c[d]]=b[c[d]];return a}}(),F=l.utils.assign,O=new e.Vector2,y=new e.Vector3,qa=new e.Raycaster,I=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,h=this.backgroundColor,f=this.contextAttributes,l=this._element,k=this._threeRenderer,m=this.rendererClass||e.WebGLRenderer;k&&k instanceof m||(k&&k.dispose(),f=F({alpha:!0,antialias:g},f),(k=l.getContext("webgl2",f)||void 0)||console.info("webgl2 init failed, trying webgl"),k=this._threeRenderer=new m(F({canvas:l,context:k},f)));f=this.shadows;k.shadowMap.enabled=!!f;f&&"object"===typeof f&&F(k.shadowMap,f);h!==this._bgColor&&(this._threeRenderer.setClearColor(new e.Color(h|| | ||
0),null!=h?1:0),this._bgColor=h);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 F({key:"camera",facade:da,aspect:this.width/this.height},this.camera)};b.prototype._getSceneDef=function(){return{key:"scene",facade:pa,lights:this.lights,objects:this.objects,fog:this.fog,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],h,b,c)}var b=this.getChildByKey("scene").threeObject,c=this.getChildByKey("camera").threeObject,h=this._threeRenderer,e=this.eventRegistry;e.forEachListenerOfType("beforerender",a,this);h.render(b,c);e.forEachListenerOfType("afterrender", | ||
a,this);if(e=this.onStatsUpdate){var f=h.info,k=f.memory;f=f.render;k={"WebGL Draw Calls":f.calls,"WebGL Geometries":k.geometries,"WebGL Textures":k.textures,"WebGL Triangles":f.triangles};f.points&&(k["WebGL Points"]=f.points);f.lines&&(k["WebGL Lines"]=f.lines);e(k)}};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){y.set(a,b,c);a=this.getChildByKey("camera");a.updateMatrices(); | ||
a=a.threeObject;y.applyMatrix4(a.matrixWorldInverse);b=y.length()*(0<y.z?-1:1);y.applyMatrix4(a.projectionMatrix);return new e.Vector3((y.x+1)*this.width/2,(1-y.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 h=a.target.getBoundingClientRect();g=((b.clientX||0)-(h.left||0))/(h.width||this.width)*2-1;b=((b.clientY||0)-(h.top||0))/(h.height||this.height)* | ||
-2+1;h=this.getChildByKey("camera");h.updateMatrices();a.ray=h.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&&(qa.ray=a,d.forEachSphereOnRay(a,function(a,d){(a=(d=(a=c._object3DFacadesById)&&a[d])&&(!b||b(d))&&d.raycast&&d.raycast(qa))&&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 m);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();this._threeRenderer.forceContextLoss()};return b}(l.WorldBaseFacade);I.prototype._notifyWorldHandlers=F(Object.create(l.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 Oa="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",Pa);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}(n);var Pa={set:function(c){c!==this.$troikaVisible&&(this.$troikaVisible=c,this.$facade.notifyWorld("instanceableChanged"))},get:function(){return this.$troikaVisible}};l.utils.assign(r.prototype,{_lastInstancedMatrixVersion:-1, | ||
_instancedThreeObject:null});var ra=new e.BufferGeometry,Qa=new e.MeshBasicMaterial,P={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},B=function(c){function b(a){c.call(this,a,new e.Mesh(ra,Qa));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.material,b=this.threeObject;b.geometry=this.geometry||ra;a!==this._lastMtl&&(this._lastMtl=a,"string"===typeof a?a=new (P[a]||e.MeshStandardMaterial):a&&a.isMaterial||(a="function"===typeof a?new a:new e.MeshStandardMaterial),b.material=a);if(a=this._dirtyMtlProps)b.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}(n),Ra={type:1,id:1,uuid:1,version:1};Object.keys(P).forEach(function(c){var b=new P[c];c=function(a){b.hasOwnProperty(a)&&!Ra.hasOwnProperty(a)&&Object.defineProperty(B.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 sa=l.utils.memoize(function(){return new e.BoxBufferGeometry(1,1,1,1,1)}),Sa=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 sa()};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}(B),Ta=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 sa()};a.size.set= | ||
function(a){this.scale=a};a.size.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(B),Ua=l.utils.memoize(function(){return(new e.PlaneBufferGeometry(1,1,1,1)).rotateX(-Math.PI/2)}),Va=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},depth:{configurable:!0}};a.geometry.get=function(){return Ua()};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}(B),ta=Object.create(null,{low:{get:l.utils.memoize(function(){return new e.SphereBufferGeometry(1,16,12)})},medium:{get:l.utils.memoize(function(){return new e.SphereBufferGeometry(1,32,24)})},high:{get:l.utils.memoize(function(){return new e.SphereBufferGeometry(1,64,48)})}}),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},radius:{configurable:!0}};a.geometry.get=function(){return ta[this.detail]||ta.medium};a.radius.set=function(a){this.scale=a};a.radius.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(B),J=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 w.createElement(c,l.utils.assign({},a,{onCanvasRef:this._onCanvasRef,canvasStyle:a.canvasStyle||b.canvasStyle,worldFacade:a.worldFacade||b.worldFacade||I,worldProps:l.utils.assign({antialias:a.antialias,rendererClass:a.rendererClass,backgroundColor:a.backgroundColor,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}(l.ReactCanvasBase);J.displayName="Canvas3D";J.propTypes=l.utils.assignIf({backgroundColor:p.any,lights:p.array,camera:p.object,objects:p.oneOfType([p.array,p.object]).isRequired,antialias:p.bool,onBackgroundClick:p.func,rendererClass:p.func},l.ReactCanvasBase.commonPropTypes);J.contextType=w.createContext({worldFacade:I,worldProps:{},onCanvasRef:null,canvasStyle:null});Object.defineProperty(f,"Facade",{enumerable:!0,get:function(){return l.Facade}}); | ||
Object.defineProperty(f,"ListFacade",{enumerable:!0,get:function(){return l.ListFacade}});Object.defineProperty(f,"ParentFacade",{enumerable:!0,get:function(){return l.ParentFacade}});Object.defineProperty(f,"createDerivedMaterial",{enumerable:!0,get:function(){return t.createDerivedMaterial}});f.AmbientLight3DFacade=fa;f.BoxFacade=Sa;f.Canvas3D=J;f.CubeFacade=Ta;f.DirectionalLight3DFacade=ha;f.Group3DFacade=ea;f.HemisphereLight3DFacade=ka;f.HtmlOverlay3DFacade=Ea;f.Instanceable3DFacade=r;f.InstancingManager= | ||
M;f.MeshFacade=B;f.Object3DFacade=n;f.OrthographicCamera3DFacade=L;f.PerspectiveCamera3DFacade=da;f.PlaneFacade=Va;f.PointLight3DFacade=ja;f.RectAreaLight3DFacade=Fa;f.Scene3DFacade=pa;f.SphereFacade=Wa;f.SpotLight3DFacade=ia;f.World3DFacade=I;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);Oa.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,l.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.17.1", | ||
"version": "0.18.0", | ||
"description": "Troika 3D", | ||
@@ -18,4 +18,4 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"dependencies": { | ||
"troika-core": "^0.17.1", | ||
"troika-three-utils": "^0.17.1" | ||
"troika-core": "^0.18.0", | ||
"troika-three-utils": "^0.18.0" | ||
}, | ||
@@ -25,3 +25,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "0708fdbb59d0073095124b1ac669bbe84fc640e9" | ||
"gitHead": "1f63d8e464644507912859c2b35a820899bf889a" | ||
} |
@@ -6,2 +6,3 @@ import { PointerEventTarget, Facade, utils } from 'troika-core' | ||
const singletonVec3 = new Vector3() | ||
const singletonVec3b = new Vector3() | ||
const notifyWorldGetter = (function() { | ||
@@ -177,10 +178,9 @@ const obj = { | ||
* Get this object's current position in world space | ||
* @param {Vector3} vec3 - optional Vector3 object to populate with the position; | ||
* @param {Vector3} [vec3] - optional Vector3 object to populate with the position; | ||
* if not passed in a new one will be created. | ||
* @returns {Vector3} | ||
*/ | ||
getWorldPosition(vec3 = new Vector3()) { | ||
getWorldPosition(vec3 ) { | ||
this.updateMatrices() | ||
vec3.setFromMatrixPosition(this.threeObject.matrixWorld) | ||
return vec3 | ||
return (vec3 || new Vector3()).setFromMatrixPosition(this.threeObject.matrixWorld) | ||
} | ||
@@ -190,8 +190,10 @@ | ||
* Get the current position vector of the world's camera. | ||
* @param {Vector3} [vec3] - optional Vector3 object to populate with the position; | ||
* if not passed in a new one will be created. | ||
* @returns {Vector3} | ||
*/ | ||
getCameraPosition() { | ||
notifyWorldGetter.value = null | ||
this.notifyWorld('getCameraPosition', notifyWorldGetter) | ||
return notifyWorldGetter.value | ||
getCameraPosition(vec3 ) { | ||
vec3 = vec3 || new Vector3() | ||
this.notifyWorld('getCameraPosition', vec3) | ||
return vec3 | ||
} | ||
@@ -216,3 +218,3 @@ | ||
getCameraDistance() { | ||
let cameraPos = this.getCameraPosition() | ||
let cameraPos = this.getCameraPosition(singletonVec3b) | ||
let objectPos = this.getWorldPosition(singletonVec3) | ||
@@ -219,0 +221,0 @@ return cameraPos.distanceTo(objectPos) |
@@ -302,7 +302,5 @@ import { WorldBaseFacade, utils } from 'troika-core' | ||
{ | ||
getCameraPosition(source, data) { | ||
getCameraPosition(source, outputVec3) { | ||
// We decompose from the world matrix here to handle pose transforms on top of the configured position | ||
const camMatrix = this.getChildByKey('camera').threeObject.matrixWorld.elements | ||
const position = new Vector3(camMatrix[12], camMatrix[13], camMatrix[14]) | ||
data.callback(position) | ||
outputVec3.setFromMatrixPosition(this.getChildByKey('camera').threeObject.matrixWorld) | ||
}, | ||
@@ -309,0 +307,0 @@ getCameraFacade(source, data) { |
@@ -15,2 +15,9 @@ // Troika 3D exports | ||
// Primitives | ||
export {BoxFacade} from './facade/primitives/BoxFacade.js' | ||
export {CubeFacade} from './facade/primitives/CubeFacade.js' | ||
export {MeshFacade} from './facade/primitives/MeshFacade.js' | ||
export {PlaneFacade} from './facade/primitives/PlaneFacade.js' | ||
export {SphereFacade} from './facade/primitives/SphereFacade.js' | ||
// React entry point | ||
@@ -17,0 +24,0 @@ export {default as Canvas3D} from './react/Canvas3D.js' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
412301
27
9307
+ Addedtroika-animation@0.18.0(transitive)
+ Addedtroika-core@0.18.0(transitive)
+ Addedtroika-three-utils@0.18.0(transitive)
- Removedtroika-animation@0.17.1(transitive)
- Removedtroika-core@0.17.1(transitive)
- Removedtroika-three-utils@0.17.1(transitive)
Updatedtroika-core@^0.18.0
Updatedtroika-three-utils@^0.18.0