/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Sphere as r}from"../../../../../geometry/support/sphere.js";import{maxScale as i}from"../../../support/mathUtils.js";import{Octree as o}from"../Octree.js";class a extends o{constructor(e,s){super(t=>new r(this._instanceData.view.boundingSphere.getVec(t,m)),{maximumDepth:25}),this._instanceData=e,this._boundingSphere=s,this._tmpSphere=new r,this._tmpMat4=t()}addInstance(t){const s=this._instanceData.view.boundingSphere,r=this._instanceData.getCombinedModelTransform(t,this._tmpMat4);e(this._tmpSphere.center,this._boundingSphere.center,r),this._tmpSphere.radius=this._boundingSphere.radius*i(r),s.setVec(t,this._tmpSphere.toVec4()),this.add([t])}removeInstance(t){this.remove([t])}}const m=s();export{a as InstanceOctree};
