Comparing version 0.34.2 to 0.35.0
@@ -0,0 +0,0 @@ import {Ray, Sphere, Vector3} from 'three' |
@@ -6,2 +6,10 @@ # Change Log | ||
# [0.35.0](https://github.com/protectwise/troika/compare/v0.34.2...v0.35.0) (2020-11-16) | ||
**Note:** Version bump only for package troika-3d | ||
## [0.34.2](https://github.com/protectwise/troika/compare/v0.34.1...v0.34.2) (2020-11-09) | ||
@@ -8,0 +16,0 @@ |
@@ -1,85 +0,85 @@ | ||
'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&& | ||
"object"===typeof c&&"default"in c?c:{"default":c}}function ya(c,b){return c.distance-b.distance}function S(c){return!1===c.isRenderable&&(!c.children.length||c.children.every(S))}function T(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=za}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor=d;d.prototype.afterUpdate=function(){this.lookAt&&(U.copy(this.lookAt),V.copy(this.up||e.Object3D.DefaultUp),W.lookAt(this.threeObject.position,U,V),B.setFromRotationMatrix(W),this.quaternionX=B.x,this.quaternionY=B.y,this.quaternionZ=B.z,this.quaternionW=B.w);a.prototype.afterUpdate.call(this)};d.prototype.updateMatrices=function(){var d=this.threeObject;this._projectionChanged&& | ||
(d.updateProjectionMatrix(),this._projectionChanged=!1,this._projectionMatrixVersion=Aa++);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=X.ray=new e.Ray;X.setFromCamera(Ba.set(a,d),this.threeObject);return b};return d}(m);b.forEach(function(a){d(a,!0)});a&&a.forEach(function(a){d(a,!1)});return g}function y(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}(Y);a&&Object.defineProperties(d.prototype,a);return d}function Ca(c){var b=c.instanceUniforms,a=b?b.sort().join("|"):"",d=Z.get(c);d&&d._instanceUniformsKey===a|| | ||
(d=x.createDerivedMaterial(c,{defines:{TROIKA_INSTANCED_UNIFORMS:a},customRewriter:function(a){return Da(a.vertexShader,a.fragmentShader,b)}}),d._instanceUniformsKey=a,Z.set(c,d));return d}function Da(c,b,a){void 0===a&&(a=[]);var d=aa.test(c),g=ba.test(c),l=ca.test(c),u=x.getShaderUniformTypes(c),e=x.getShaderUniformTypes(b),h=["\nattribute vec4 troika_modelMatrixRow0;\nattribute vec4 troika_modelMatrixRow1;\nattribute vec4 troika_modelMatrixRow2;\nmat4 troika_modelMatrix;\nmat4 troika_modelViewMatrix;\nmat3 troika_normalMatrix;\n"], | ||
C=[],f=[];if(d||g||l)c=c.replace(aa,F),C.push(Ea);if(g||l)c=c.replace(ba,F),C.push("\ntroika_modelViewMatrix = viewMatrix * troika_modelMatrix;\n");l&&(c=c.replace(ca,F),C.push("\ntroika_normalMatrix = transposeMat3(inverse(mat3(troika_modelViewMatrix)));\n"),/\binverse\s*\(/.test(c)||h.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 l=new RegExp("\\b"+a+"\\b","g");h.push("attribute "+(d||g)+" troika_"+a+";");d&&(c=c.replace(l,F));g&&(b=b.replace(l,Fa),d="varying "+g+" troika_vary_"+a+";",h.push(d),f.push(d),C.push("troika_vary_"+a+" = troika_"+a+";"))}});c="\n"+h.join("\n")+"\n"+c.replace(x.voidMainRegExp,"\n $&\n "+C.join("\n")+"\n");f.length&&(b="\n"+f.join("\n")+"\n"+b);return{vertexShader:c,fragmentShader:b}}function da(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)}function ea(c,b){var a=c.uniforms;return a&&a[b]?a[b].value:(a=x.getShadersForMaterial(c).uniforms)&&a[b]?a[b].value:null}function K(c){return c[c.hasOwnProperty("instanceCount")?"instanceCount":"maxInstancedCount"]}function fa(c,b){c[c.hasOwnProperty("instanceCount")?"instanceCount":"maxInstancedCount"]=b}var ha=R(n);n=R(A);A=k.utils.assign;var ia=k.utils.forOwn,ja=new e.Vector3, | ||
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);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})}) | ||
'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,k,z,v,p){function xa(c,b){return c.distance-b.distance}function S(c){return!1=== | ||
c.isRenderable&&(!c.children.length||c.children.every(S))}function T(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=ya}a&&(d.__proto__=a);d.prototype=Object.create(a&&a.prototype);d.prototype.constructor= | ||
d;d.prototype.afterUpdate=function(){this.lookAt&&(U.copy(this.lookAt),V.copy(this.up||e.Object3D.DefaultUp),W.lookAt(this.threeObject.position,U,V),B.setFromRotationMatrix(W),this.quaternionX=B.x,this.quaternionY=B.y,this.quaternionZ=B.z,this.quaternionW=B.w);a.prototype.afterUpdate.call(this)};d.prototype.updateMatrices=function(){var d=this.threeObject;this._projectionChanged&&(d.updateProjectionMatrix(),this._projectionChanged=!1,this._projectionMatrixVersion=za++);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=X.ray=new e.Ray;X.setFromCamera(Aa.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 A(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}(Y);a&&Object.defineProperties(d.prototype,a);return d}function Ba(c){var b=c.instanceUniforms,a=b?b.sort().join("|"):"",d=Z.get(c);d&&d._instanceUniformsKey===a||(d=z.createDerivedMaterial(c,{defines:{TROIKA_INSTANCED_UNIFORMS:a},customRewriter:function(a){return Ca(a.vertexShader,a.fragmentShader, | ||
b)}}),d._instanceUniformsKey=a,Z.set(c,d));return d}function Ca(c,b,a){void 0===a&&(a=[]);var d=aa.test(c),g=ba.test(c),l=ca.test(c),w=z.getShaderUniformTypes(c),e=z.getShaderUniformTypes(b),h=["\nattribute vec4 troika_modelMatrixRow0;\nattribute vec4 troika_modelMatrixRow1;\nattribute vec4 troika_modelMatrixRow2;\nmat4 troika_modelMatrix;\nmat4 troika_modelViewMatrix;\nmat3 troika_normalMatrix;\n"],C=[],f=[];if(d||g||l)c=c.replace(aa,F),C.push(Da);if(g||l)c=c.replace(ba,F),C.push("\ntroika_modelViewMatrix = viewMatrix * troika_modelMatrix;\n"); | ||
l&&(c=c.replace(ca,F),C.push("\ntroika_normalMatrix = transposeMat3(inverse(mat3(troika_modelViewMatrix)));\n"),/\binverse\s*\(/.test(c)||h.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=w[a],g=e[a];if(d||g){var l=new RegExp("\\b"+a+"\\b","g");h.push("attribute "+(d||g)+" troika_"+a+";");d&&(c=c.replace(l,F));g&&(b=b.replace(l,Ea),d="varying "+g+" troika_vary_"+a+";",h.push(d),f.push(d),C.push("troika_vary_"+a+" = troika_"+a+";"))}});c="\n"+h.join("\n")+"\n"+c.replace(z.voidMainRegExp,"\n $&\n "+C.join("\n")+"\n");f.length&&(b="\n"+f.join("\n")+"\n"+b);return{vertexShader:c,fragmentShader:b}}function da(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)}function ea(c,b){var a=c.uniforms;return a&&a[b]?a[b].value:(a=z.getShadersForMaterial(c).uniforms)&&a[b]?a[b].value:null}function K(c){return c[c.hasOwnProperty("instanceCount")?"instanceCount":"maxInstancedCount"]}function fa(c,b){c[c.hasOwnProperty("instanceCount")?"instanceCount":"maxInstancedCount"]=b}v=v&&Object.prototype.hasOwnProperty.call(v,"default")?v["default"]:v;p=p&& | ||
Object.prototype.hasOwnProperty.call(p,"default")?p["default"]:p;var L=k.utils.assign,ha=k.utils.forOwn,ia=new e.Vector3,Fa=new e.Vector3,u=function(){var c={callback:function(b){c.value=b},value:null};return c}(),Ga={type:"removed"},D=[],Ha=0,Ia=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);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=++Ha;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(){u.value=null;this.notifyWorld("getCameraFacade",u);return u.value};b.prototype.getCameraDistance=function(){var a=this.getCameraPosition(Fa),d=this.getWorldPosition(ia);return a.distanceTo(d)};b.prototype.getProjectedPosition=function(a,d,b){this.updateMatrices();u.value=null;u.worldPosition=ia.set(a||0,d||0,b||0).applyMatrix4(this.threeObject.matrixWorld);this.notifyWorld("projectWorldPosition", | ||
u);return u.value};b.prototype.getSceneFacade=function(){u.value=null;this.notifyWorld("getSceneFacade",u);return u.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=++Ia);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(xa),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(Ga),!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(n.prototype,c,{get:function(){return this.threeObject[c]}, | ||
set:function(b){this.threeObject[c]=b}})});n.prototype.raycastSide=null;ha({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){ha(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});k.Facade.defineEventProperty(n,"onBeforeRender","beforerender");k.Facade.defineEventProperty(n,"onAfterRender","afterrender");var ya=function(){},X=new e.Raycaster,Aa=new e.Vector2,U=new e.Vector3,W=new e.Matrix4,B=new e.Quaternion,V=new e.Vector3(0,1,0),za=0,ja=T(e.PerspectiveCamera,["fov","aspect","near","far"],["focus","filmGauge","filmOffset"]); | ||
L=T(e.OrthographicCamera,"left right top bottom near far".split(" "));var ka=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),Ja=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),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}(n);"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 la=A(e.AmbientLight),ma=A(e.DirectionalLight,e.DirectionalLightHelper),na=A(e.SpotLight,e.SpotLightHelper),oa=A(e.PointLight,e.PointLightHelper),pa=A(e.HemisphereLight,e.HemisphereLightHelper,{groundColor:{set:function(c){this.threeObject.groundColor.set(c)}, | ||
get:function(){return this.threeObject.groundColor.getHex()}}}),Ka=A(e.RectAreaLight),Da="\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,qa=/\buniform\s+(int|float|vec[234])\s+$/,F=function(c,b,a){return qa.test(a.substr(0,b))?c:"troika_"+c},Ea=function(c,b,a){return qa.test(a.substr(0,b))?c:"troika_vary_"+ | ||
c},Z=new WeakMap,M=k.utils.assign,N=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),p=f.material.instanceUniforms,n=a[k]||(a[k]=[]),m= | ||
(k=n[n.length-1])&&k.geometry;if(!m||128===K(m)){k=this._getBatchObject(f);m=k.geometry;for(var q=m._instanceAttrs.matrix,t=0;3>t;t++)q[t].version++;if(p)for(q=m._instanceAttrs.uniforms,t=p.length;t--;)q[p[t]].version++;n.push(k)}n=K(m);fa(m,n+1);q=m._instanceAttrs.matrix;h=h.matrixWorld.elements;q[0].setXYZW(n,h[0],h[4],h[8],h[12]);q[1].setXYZW(n,h[1],h[5],h[9],h[13]);q[2].setXYZW(n,h[2],h[6],h[10],h[14]);if(p)for(q=m._instanceAttrs.uniforms,h=p.length;h--;){t=p[h];m=q[t];var r=c._instanceUniforms; | ||
t=r&&t in r?r[t]:ea(f.material,t);da(m,n,t)}c._instancingBatchObject=k;c._instancingBatchAttrOffset=n}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++,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),w=this._getInstanceUniformSizes(c);b=this._batchGeometryPool.borrow(l,b,w);fa(b,0);var J=Ba(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=M({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}(ka),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;M(d,b);d.attributes=M({},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 w in a)g=a[w],g=new e.InstancedBufferAttribute(new Float32Array(128*g),g),g.setUsage?g.setUsage(35048):g.dynamic=!0,d.attributes["troika_"+w]=g,b.uniforms[w]=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=N.prototype;r._notifyWorldHandlers={instanceableAdded:r._onInstanceAdded,instanceableRemoved:r._onInstanceRemoved,instanceableChanged:r._onInstanceChanged,instanceableMatrixChanged:r._onInstanceMatrixChanged,instanceableUniformChanged:r._onInstanceUniformChanged};var La={ambient:la,directional:ma,spot:na,point:oa,hemisphere:pa},Ma=[{distance:Infinity}],Na=new e.Sphere(void 0,Infinity),ra= | ||
[null],sa=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:N,children:this.objects},b=this.lights;b&&(a=[a],Array.isArray(b)|| | ||
(ra[0]=b,b=ra),b.forEach(function(b,d){var c=b.facade||La[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 Na};b.prototype.raycast= | ||
function(a){return Ma};Object.defineProperties(b.prototype,a);return b}(n);r=k.utils.assign;var Oa=k.utils.forOwn,O=new e.Sphere,Pa=Math.sqrt(3),m=function(){this.root=null;this.keysToLeaves=Object.create(null)};m.prototype.putSpheres=function(c){var b=this;Oa(c,function(a,c){b.putSphere(c,a)})};m.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))};m.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 q;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 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,l=d.cy,e=d.cz,f=d.cr,h=new q;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}};m.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=Qa(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 q;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}};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,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)};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,l){c(d)&&b.call(a,d,l)}this.walkTree(function(a){if(a.isLeaf)a.forEachLeafSphere(d);else if(O.center.set(a.cx,a.cy,a.cz),O.radius=a.cr* | ||
Pa+a.maxRadius,!c(O))return!1;return!0})};var q=function(){};q.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};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),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};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;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)};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 Qa=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}}(),E=k.utils.assign,P=new e.Vector2,x=new e.Vector3,ta=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:ja,aspect:this.width/this.height},this.camera)};b.prototype._getSceneDef=function(){return{key:"scene",facade:sa,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(P);P.width===a&&P.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){x.set(a,b,c);a=this.getChildByKey("camera");a.updateMatrices();a=a.threeObject;x.applyMatrix4(a.matrixWorldInverse);b=x.length()*(0<x.z?-1:1);x.applyMatrix4(a.projectionMatrix);return new e.Vector3((x.x+1)*this.width/2,(1-x.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&&(ta.ray=a,d.forEachSphereOnRay(a,function(a,d){(a=(d=(a=c._object3DFacadesById)&& | ||
a[d])&&(!b||b(d))&&d.raycast&&d.raycast(ta))&&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()};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 Ra="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",Sa);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 Sa={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 Q=new e.BufferGeometry,Ta=new e.MeshBasicMaterial,R={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},y=function(c){function b(a){c.call(this, | ||
a,new e.Mesh(Q,Ta));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||Q)!==g.geometry&&(this.autoDisposeGeometry&&g.geometry.dispose(),g.geometry=a||Q);b!==this._lastMtl&&(this._lastMtl=b,"string"===typeof b?b=new (R[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}(n),Ua={type:1,id:1,uuid:1,version:1};Object.keys(R).forEach(function(c){var b= | ||
new R[c];c=function(a){b.hasOwnProperty(a)&&!Ua.hasOwnProperty(a)&&Object.defineProperty(y.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 ua=k.utils.memoize(function(){return new e.BoxBufferGeometry(1,1,1,1,1)}),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},height:{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.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}(y), | ||
va=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},{})),Wa=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 va[this.detail]|| | ||
va.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}(y),Xa=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 ua()};a.size.set=function(a){this.scale=a};a.size.get=function(){return this.scale};Object.defineProperties(b.prototype, | ||
a);return b}(y),Ya=k.utils.memoize(function(){return(new e.PlaneBufferGeometry(1,1,1,1)).rotateX(-Math.PI/2)}),Za=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 Ya()};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}(y),wa=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},{})),$a=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 wa[this.detail]||wa.medium};a.radius.set=function(a){this.scale=a};a.radius.get=function(){return this.scale};Object.defineProperties(b.prototype,a);return b}(y),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 v.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:p.any,background:p.any,environment:p.any,outputEncoding:p.number,toneMapping:p.number,lights:p.array,camera:p.object,objects:p.oneOfType([p.array,p.object]).isRequired,antialias:p.bool,onBackgroundClick:p.func,rendererClass:p.func},k.ReactCanvasBase.commonPropTypes);I.contextType=v.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 z.createDerivedMaterial}});f.AmbientLight3DFacade=la;f.BoxFacade=Va;f.Canvas3D=I;f.CircleFacade=Wa;f.CubeFacade=Xa;f.DirectionalLight3DFacade=ma;f.Group3DFacade= | ||
ka;f.HemisphereLight3DFacade=pa;f.HtmlOverlay3DFacade=Ja;f.Instanceable3DFacade=r;f.InstancingManager=N;f.MeshFacade=y;f.Object3DFacade=n;f.OrthographicCamera3DFacade=L;f.PerspectiveCamera3DFacade=ja;f.PlaneFacade=Za;f.PointLight3DFacade=oa;f.RectAreaLight3DFacade=Ka;f.Scene3DFacade=sa;f.SphereFacade=$a;f.SpotLight3DFacade=na;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); | ||
Ra.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.2", | ||
"version": "0.35.0", | ||
"description": "Troika 3D", | ||
@@ -17,6 +17,6 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"dependencies": { | ||
"troika-core": "^0.34.0", | ||
"troika-three-utils": "^0.34.0" | ||
"troika-core": "^0.35.0", | ||
"troika-three-utils": "^0.35.0" | ||
}, | ||
"gitHead": "cbb2dab8b2fb5c39f06d88e342e3095218e5bee0" | ||
"gitHead": "0fc459bec5f330f6f040d07bfe304d10a87d73c0" | ||
} |
@@ -0,0 +0,0 @@ # Troika 3D |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ import { |
@@ -0,0 +0,0 @@ import {Group} from 'three' |
@@ -0,0 +0,0 @@ import {Object3D} from 'three' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { createDerivedMaterial, getShaderUniformTypes, voidMainRegExp } from 'troika-three-utils' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { |
@@ -0,0 +0,0 @@ import { PointerEventTarget, Facade, utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { MeshFacade } from './MeshFacade.js' |
@@ -0,0 +0,0 @@ import Object3DFacade from '../Object3DFacade.js' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { WorldBaseFacade, utils } from 'troika-core' |
@@ -0,0 +0,0 @@ import { utils } from 'troika-core' |
@@ -0,0 +0,0 @@ // Troika 3D exports |
@@ -0,0 +0,0 @@ import React from 'react' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
9645
430994
+ Addedtroika-animation@0.35.0(transitive)
+ Addedtroika-core@0.35.0(transitive)
+ Addedtroika-three-utils@0.35.0(transitive)
- Removedtroika-animation@0.34.0(transitive)
- Removedtroika-core@0.34.0(transitive)
- Removedtroika-three-utils@0.34.0(transitive)
Updatedtroika-core@^0.35.0
Updatedtroika-three-utils@^0.35.0