babylonjs-editor-tools 0.0.12 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var j=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var so=Object.prototype.hasOwnProperty;var i=(e,t)=>j(e,"name",{value:t,configurable:!0});var ao=(e,t)=>{for(var o in t)j(e,o,{get:t[o],enumerable:!0})},lo=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of io(t))!so.call(e,r)&&r!==o&&j(e,r,{get:()=>t[r],enumerable:!(n=to(t,r))||n.enumerable});return e};var co=e=>lo(j({},"__esModule",{value:!0}),e);var Xo={};ao(Xo,{animationGroupFromScene:()=>No,configureEngineToUseCompressedTextures:()=>Fo,configureShadowMapRefreshRate:()=>Pe,configureShadowMapRenderListPredicate:()=>be,createDefaultRenderingPipeline:()=>je,createMotionBlurPostProcess:()=>_e,createSSAO2RenderingPipeline:()=>Be,createSSRRenderingPipeline:()=>Ne,createVLSPostProcess:()=>Me,defaultPipelineCameraConfigurations:()=>L,disposeDefaultRenderingPipeline:()=>ye,disposeMotionBlurPostProcess:()=>pe,disposeSSAO2RenderingPipeline:()=>le,disposeSSRRenderingPipeline:()=>ie,disposeVLSPostProcess:()=>ne,generateCinematicAnimationGroup:()=>Wo,getAnimationTypeForObject:()=>K,getDefaultRenderingPipeline:()=>G,getMotionBlurPostProcess:()=>ue,getPowerOfTwoUntil:()=>D,getSSAO2RenderingPipeline:()=>Eo,getSSRRenderingPipeline:()=>xo,getVLSPostProcess:()=>Co,guiFromAsset:()=>Vo,isAbstractMesh:()=>mo,isArcRotateCamera:()=>yo,isBone:()=>uo,isCamera:()=>oe,isCinematicGroup:()=>Zo,isCinematicKey:()=>$o,isCinematicKeyCut:()=>Qo,isCinematicKeyEvent:()=>Uo,isCinematicSound:()=>qo,isDirectionalLight:()=>So,isFreeCamera:()=>fo,isGroundMesh:()=>po,isHemisphericLight:()=>Po,isInstancedMesh:()=>J,isMesh:()=>T,isPointLight:()=>ho,isSpotLight:()=>bo,isTexture:()=>ee,isTransformNode:()=>go,loadScene:()=>Oo,motionBlurPostProcessCameraConfigurations:()=>B,nodeFromDescendants:()=>wo,nodeFromScene:()=>Mo,parseCinematic:()=>Ho,parseCinematicKeyValue:()=>C,parseDefaultRenderingPipeline:()=>Se,parseMotionBlurPostProcess:()=>fe,parseSSAO2RenderingPipeline:()=>me,parseSSRRenderingPipeline:()=>ae,parseVLSPostProcess:()=>te,particleSystemFromScene:()=>Lo,serializeDefaultRenderingPipeline:()=>he,serializeMotionBlurPostProcess:()=>ge,serializeSSAO2RenderingPipeline:()=>ce,serializeSSRRenderingPipeline:()=>se,serializeVLSPostProcess:()=>re,setDefaultRenderingPipelineRef:()=>vo,setMotionBlurPostProcessRef:()=>Do,setSSAO2RenderingPipelineRef:()=>To,setSSRRenderingPipelineRef:()=>Ao,setVLSPostProcessRef:()=>Io,soundFromScene:()=>Bo,ssaoRenderingPipelineCameraConfigurations:()=>V,ssrRenderingPipelineCameraConfigurations:()=>N,visibleAsBoolean:()=>_o,visibleAsColor3:()=>zo,visibleAsColor4:()=>jo,visibleAsEntity:()=>Yo,visibleAsNumber:()=>Go,visibleAsVector2:()=>Ko,visibleAsVector3:()=>ko,vlsPostProcessCameraConfigurations:()=>w});module.exports=co(Xo);function mo(e){switch(e.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}i(mo,"isAbstractMesh");function T(e){switch(e.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}i(T,"isMesh");function J(e){return e.getClassName?.()==="InstancedMesh"}i(J,"isInstancedMesh");function uo(e){return e.getClassName?.()==="Bone"}i(uo,"isBone");function po(e){return e.getClassName?.()==="GroundMesh"}i(po,"isGroundMesh");function go(e){return e.getClassName?.()==="TransformNode"}i(go,"isTransformNode");function ee(e){return e?.getClassName?.()==="Texture"}i(ee,"isTexture");function oe(e){switch(e.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}i(oe,"isCamera");function fo(e){switch(e.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}i(fo,"isFreeCamera");function yo(e){return e.getClassName?.()==="ArcRotateCamera"}i(yo,"isArcRotateCamera");function ho(e){return e.getClassName?.()==="PointLight"}i(ho,"isPointLight");function So(e){return e.getClassName?.()==="DirectionalLight"}i(So,"isDirectionalLight");function bo(e){return e.getClassName?.()==="SpotLight"}i(bo,"isSpotLight");function Po(e){return e.getClassName?.()==="HemisphericLight"}i(Po,"isHemisphericLight");function Y(e,t){let o=t.soundTracks??[];o.length||o.push(t.mainSoundTrack);for(let n=0,r=o.length;n<r;n++){let l=o[n].soundCollection.find(s=>s.id===e);if(l)return l}return null}i(Y,"getSoundById");var H=require("babylonjs"),W=require("babylonjs"),Ee=require("babylonjs-gui");function Te(e,t,o,n,r){let l=n.constructor;l&&(l._NodesFromScene?.forEach(s=>{n[s.propertyKey.toString()]=e.getNodeByName(s.nodeName)}),l._NodesFromDescendants?.forEach(s=>{let c=t.getDescendants?.(s.directDescendantsOnly,u=>u.name===s.nodeName)[0];n[s.propertyKey.toString()]=c??null}),l._AnimationGroups?.forEach(s=>{n[s.propertyKey.toString()]=e.getAnimationGroupByName(s.animationGroupName)}),l._SoundsFromScene?.forEach(s=>{let c=e.getSoundByName?.(s.soundName);n[s.propertyKey.toString()]=c??null}),l._GuiFromAsset?.forEach(async s=>{let c=`${r}assets/${s.pathInAssets}`;try{let y=await(await fetch(c)).json(),P=Ee.AdvancedDynamicTexture.CreateFullscreenUI(y.name,!0,e);P.parseSerializedObject(y.content,!1),n[s.propertyKey.toString()]=P,s.onGuiCreated?.(n,P)}catch(u){throw console.error(`Failed to load GUI from asset: ${c}`),u}}),l._ParticleSystemsFromScene?.forEach(s=>{let c=e.particleSystems?.find(u=>u.name===s.particleSystemName);n[s.propertyKey.toString()]=c}),l._VisibleInInspector?.forEach(s=>{let c=s.propertyKey.toString(),u=o.values;if(u.hasOwnProperty(c)&&u[c].hasOwnProperty("value")){let y=u[c].value;switch(s.configuration.type){case"number":case"boolean":n[c]=y;break;case"vector2":n[c]=W.Vector2.FromArray(y);break;case"vector3":n[c]=W.Vector3.FromArray(y);break;case"color3":n[c]=H.Color3.FromArray(y);break;case"color4":n[c]=H.Color4.FromArray(y);break;case"entity":switch(s.configuration.entityType){case"node":n[c]=e.getNodeById(y)??null;break;case"animationGroup":n[c]=e.getAnimationGroupByName(y)??null;break;case"sound":n[c]=Y(y,e);break;case"particleSystem":n[c]=e.particleSystems?.find(R=>R.id===y)??null;break}break}}}))}i(Te,"applyDecorators");function M(e,t,o,n){t.metadata&&(t.metadata.scripts?.forEach(r=>{if(!r.enabled)return;let l=o[r.key];if(l)if(l.default){let s=new l.default(t);Te(e,t,r,s,n),s.onStart&&e.onBeforeRenderObservable.addOnce(()=>s.onStart()),s.onUpdate&&e.onBeforeRenderObservable.add(()=>s.onUpdate())}else l.onStart&&e.onBeforeRenderObservable.addOnce(()=>l.onStart(t)),l.onUpdate&&e.onBeforeRenderObservable.add(()=>l.onUpdate(t))}),t.metadata.scripts=void 0)}i(M,"applyScriptForObject");var _=require("babylonjs"),De=require("babylonjs");function ve(e){let t=e.metadata?.physicsAggregate;if(!t)return;let o;T(e)?o=e:J(e)&&(o=e.sourceMesh);let n=new De.PhysicsAggregate(e,t.shape.type,{mesh:o,mass:t.massProperties.mass});n.body.setMassProperties({mass:t.massProperties.mass,inertia:t.massProperties.inertia?_.Vector3.FromArray(t.massProperties.inertia):void 0,centerOfMass:t.massProperties.centerOfMass?_.Vector3.FromArray(t.massProperties.centerOfMass):void 0,inertiaOrientation:t.massProperties.inertiaOrientation?_.Quaternion.FromArray(t.massProperties.inertiaOrientation):void 0}),n.shape.density=t.shape.density,n.body.setMotionType(t.body.motionType),n.shape.material=t.material,e.physicsAggregate=n,e.metadata.physicsAggregate=void 0}i(ve,"configurePhysicsAggregate");var Re=require("babylonjs"),Oe=require("babylonjs"),Fe=require("babylonjs"),S=null,w=new Map;function Co(){return S}i(Co,"getVLSPostProcess");function Io(e){S=e}i(Io,"setVLSPostProcessRef");function ne(e){S&&e.activeCamera&&(S.dispose(e.activeCamera),S=null)}i(ne,"disposeVLSPostProcess");function Me(e,t){return t??=e.meshes.find(o=>T(o)),S=new Fe.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,e.activeCamera,t,100,Oe.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1),S}i(Me,"createVLSPostProcess");function re(){return S?{meshId:S.mesh?.id,exposure:S.exposure,decay:S.decay,weight:S.weight,density:S.density,invert:S.invert,useCustomMeshPosition:S.useCustomMeshPosition,customMeshPosition:S.customMeshPosition.asArray()}:null}i(re,"serializeVLSPostProcess");function te(e,t){let o=null;if(t.meshId){let r=e.getMeshById(t.meshId);r&&T(r)&&(o=r)}let n=Me(e,o);return n.exposure=t.exposure,n.decay=t.decay,n.weight=t.weight,n.density=t.density,n.invert=t.invert,n.useCustomMeshPosition=t.useCustomMeshPosition,n.customMeshPosition.copyFrom(Re.Vector3.FromArray(t.customMeshPosition)),n}i(te,"parseVLSPostProcess");var we=require("babylonjs"),m=null,N=new Map;function xo(){return m}i(xo,"getSSRRenderingPipeline");function Ao(e){m=e}i(Ao,"setSSRRenderingPipelineRef");function ie(){m&&(m.dispose(),m=null)}i(ie,"disposeSSRRenderingPipeline");function Ne(e,t){return m=new we.SSRRenderingPipeline("SSRRenderingPipeline",e,[t]),m.samples=4,m}i(Ne,"createSSRRenderingPipeline");function se(){return m?{samples:m.samples,step:m.step,thickness:m.thickness,strength:m.strength,reflectionSpecularFalloffExponent:m.reflectionSpecularFalloffExponent,maxSteps:m.maxSteps,maxDistance:m.maxDistance,roughnessFactor:m.roughnessFactor,reflectivityThreshold:m.reflectivityThreshold,blurDispersionStrehgth:m.blurDispersionStrength,clipToFrustum:m.clipToFrustum,enableSmoothReflections:m.enableSmoothReflections,enableAutomaticThicknessComputation:m.enableAutomaticThicknessComputation,attenuateFacingCamera:m.attenuateFacingCamera,attenuateScreenBorders:m.attenuateScreenBorders,attenuateIntersectionDistance:m.attenuateIntersectionDistance,attenuateBackfaceReflection:m.attenuateBackfaceReflection,blurDownsample:m.blurDownsample,selfCollisionNumSkip:m.selfCollisionNumSkip,ssrDownsample:m.ssrDownsample,backfaceDepthTextureDownsample:m.backfaceDepthTextureDownsample}:null}i(se,"serializeSSRRenderingPipeline");function ae(e,t,o){if(m)return m;let n=Ne(e,t);return n.samples=o.samples,n.step=o.step,n.thickness=o.thickness,n.strength=o.strength,n.reflectionSpecularFalloffExponent=o.reflectionSpecularFalloffExponent,n.maxSteps=o.maxSteps,n.maxDistance=o.maxDistance,n.roughnessFactor=o.roughnessFactor,n.reflectivityThreshold=o.reflectivityThreshold,n.blurDispersionStrength=o.blurDispersionStrehgth,n.clipToFrustum=o.clipToFrustum,n.enableSmoothReflections=o.enableSmoothReflections,n.enableAutomaticThicknessComputation=o.enableAutomaticThicknessComputation,n.attenuateFacingCamera=o.attenuateFacingCamera,n.attenuateScreenBorders=o.attenuateScreenBorders,n.attenuateIntersectionDistance=o.attenuateIntersectionDistance,n.attenuateBackfaceReflection=o.attenuateBackfaceReflection,n.blurDownsample=o.blurDownsample,n.selfCollisionNumSkip=o.selfCollisionNumSkip,n.ssrDownsample=o.ssrDownsample,n.backfaceDepthTextureDownsample=o.backfaceDepthTextureDownsample,n}i(ae,"parseSSRRenderingPipeline");var Ve=require("babylonjs"),d=null,V=new Map;function Eo(){return d}i(Eo,"getSSAO2RenderingPipeline");function To(e){d=e}i(To,"setSSAO2RenderingPipelineRef");function le(){d&&(d.dispose(),d=null)}i(le,"disposeSSAO2RenderingPipeline");function Be(e,t){return d=new Ve.SSAO2RenderingPipeline("SSAO2RenderingPipeline",e,1,[t]),d.samples=4,d}i(Be,"createSSAO2RenderingPipeline");function ce(){return d?{radius:d.radius,totalStrength:d.totalStrength,samples:d.samples,maxZ:d.maxZ,minZAspect:d.minZAspect,epsilon:d.epsilon,textureSamples:d.textureSamples,bypassBlur:d.bypassBlur,bilateralSamples:d.bilateralSamples,bilateralSoften:d.bilateralSoften,bilateralTolerance:d.bilateralTolerance,expensiveBlur:d.expensiveBlur}:null}i(ce,"serializeSSAO2RenderingPipeline");function me(e,t,o){if(d)return d;let n=Be(e,t);return n.radius=o.radius,n.totalStrength=o.totalStrength,n.samples=o.samples,n.maxZ=o.maxZ,n.minZAspect=o.minZAspect,n.epsilon=o.epsilon,n.textureSamples=o.textureSamples,n.bypassBlur=o.bypassBlur,n.bilateralSamples=o.bilateralSamples,n.bilateralSoften=o.bilateralSoften,n.bilateralTolerance=o.bilateralTolerance,n.expensiveBlur=o.expensiveBlur,n}i(me,"parseSSAO2RenderingPipeline");var Le=require("babylonjs"),b=null,B=new Map;function ue(){return b}i(ue,"getMotionBlurPostProcess");function Do(e){b=e}i(Do,"setMotionBlurPostProcessRef");function pe(){b&&(b.dispose(),b=null)}i(pe,"disposeMotionBlurPostProcess");function _e(e,t){return b=new Le.MotionBlurPostProcess("MotionBlurPostProcess",e,1,t),b.motionStrength=1,b.isObjectBased=!0,b}i(_e,"createMotionBlurPostProcess");function ge(){return b?{isObjectBased:b.isObjectBased,motionStrength:b.motionStrength,motionBlurSamples:b.motionBlurSamples}:null}i(ge,"serializeMotionBlurPostProcess");function fe(e,t,o){if(b)return b;let n=_e(e,t);return n.isObjectBased=o.isObjectBased,n.motionStrength=o.motionStrength,n.motionBlurSamples=o.motionBlurSamples,n}i(fe,"parseMotionBlurPostProcess");var Ge=require("babylonjs"),de=require("babylonjs"),Ke=require("babylonjs"),ke=require("babylonjs"),ze=require("babylonjs"),a=null,L=new Map;function G(){return a}i(G,"getDefaultRenderingPipeline");function vo(e){a=e}i(vo,"setDefaultRenderingPipelineRef");function ye(){a&&(a.dispose(),a=null)}i(ye,"disposeDefaultRenderingPipeline");function je(e,t){return a=new ze.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,e,[t]),a.samples=4,a.depthOfField.lensSize=512,a.depthOfField.fStop=.25,a.depthOfField.focusDistance=55e3,a}i(je,"createDefaultRenderingPipeline");function he(){return a?{samples:a.samples,fxaaEnabled:a.fxaaEnabled,imageProcessingEnabled:a.imageProcessingEnabled,exposure:a.imageProcessing?.exposure,contrast:a.imageProcessing?.contrast,fromLinearSpace:a.imageProcessing?.fromLinearSpace,toneMappingEnabled:a.imageProcessing?.toneMappingEnabled,toneMappingType:a.imageProcessing?.toneMappingType,ditheringEnabled:a.imageProcessing?.ditheringEnabled,ditheringIntensity:a.imageProcessing?.ditheringIntensity,bloomEnabled:a.bloomEnabled,bloomThreshold:a.bloomThreshold,bloomWeight:a.bloomWeight,bloomScale:a.bloomScale,bloomKernel:a.bloomKernel,sharpenEnabled:a.sharpenEnabled,sharpenEdgeAmount:a.sharpen.edgeAmount,sharpenColorAmount:a.sharpen.colorAmount,grainEnabled:a.grainEnabled,grainIntensity:a.grain.intensity,grainAnimated:a.grain.animated,depthOfFieldEnabled:a.depthOfFieldEnabled,depthOfFieldBlurLevel:a.depthOfFieldBlurLevel,lensSize:a.depthOfField.lensSize,fStop:a.depthOfField.fStop,focusDistance:a.depthOfField.focusDistance,focalLength:a.depthOfField.focalLength,vignetteEnabled:a.imageProcessing?.vignetteEnabled,vignetteColor:a.imageProcessing?.vignetteColor.asArray(),vignetteWeight:a.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:a.chromaticAberrationEnabled,aberrationAmount:a.chromaticAberration.aberrationAmount,radialIntensity:a.chromaticAberration.radialIntensity,direction:a.chromaticAberration.direction.asArray(),centerPosition:a.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:a.glowLayerEnabled,glowLayerIntensity:a.glowLayer?.intensity,glowLayerBlurKernelSize:a.glowLayer?.blurKernelSize,colorGradingEnabled:a.imageProcessing.colorGradingEnabled,colorGradingTexture:a.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:a.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:a.imageProcessing.colorCurvesEnabled,globalHue:a.imageProcessing.colorCurves?.globalHue,globalDensity:a.imageProcessing.colorCurves?.globalDensity,globalExposure:a.imageProcessing.colorCurves?.globalExposure,globalSaturation:a.imageProcessing.colorCurves?.globalSaturation,highlightsHue:a.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:a.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:a.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:a.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:a.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:a.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:a.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:a.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:a.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:a.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:a.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:a.imageProcessing.colorCurves?.shadowsSaturation}:null}i(he,"serializeDefaultRenderingPipeline");function Se(e,t,o,n){if(a)return a;let r=je(e,t);if(r.samples=o.samples,r.fxaaEnabled=o.fxaaEnabled,r.imageProcessingEnabled=o.imageProcessingEnabled,r.imageProcessing){if(r.imageProcessing.exposure=o.exposure,r.imageProcessing.contrast=o.contrast,r.imageProcessing.fromLinearSpace=o.fromLinearSpace,r.imageProcessing.toneMappingEnabled=o.toneMappingEnabled,r.imageProcessing.toneMappingType=o.toneMappingType,r.imageProcessing.ditheringEnabled=o.ditheringEnabled,r.imageProcessing.ditheringIntensity=o.ditheringIntensity,r.imageProcessing.vignetteEnabled=o.vignetteEnabled??!1,r.imageProcessing.vignetteColor=Ge.Color4.FromArray(o.vignetteColor??[0,0,0]),r.imageProcessing.vignetteWeight=o.vignetteWeight??.3,r.imageProcessing.colorGradingEnabled=o.colorGradingEnabled??!1,r.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=o.colorGradingWithGreenDepth??!0,o.colorGradingTexture){let l=null;if(o.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let s=n+o.colorGradingTexture.name;l=new ke.ColorGradingTexture(s,e),l.level=o.colorGradingTexture.level}else{let s=Ke.Texture.Parse(o.colorGradingTexture,e,n);ee(s)&&(l=s)}r.imageProcessing.colorGradingTexture=l}r.imageProcessing.colorCurvesEnabled=o.colorCurvesEnabled??!1,r.imageProcessing.colorCurves&&(r.imageProcessing.colorCurves.globalHue=o.globalHue??30,r.imageProcessing.colorCurves.globalDensity=o.globalDensity??0,r.imageProcessing.colorCurves.globalExposure=o.globalExposure??0,r.imageProcessing.colorCurves.globalSaturation=o.globalSaturation??0,r.imageProcessing.colorCurves.highlightsHue=o.highlightsHue??30,r.imageProcessing.colorCurves.highlightsDensity=o.highlightsDensity??0,r.imageProcessing.colorCurves.highlightsExposure=o.highlightsExposure??0,r.imageProcessing.colorCurves.highlightsSaturation=o.highlightsSaturation??0,r.imageProcessing.colorCurves.midtonesHue=o.midtonesHue??30,r.imageProcessing.colorCurves.midtonesDensity=o.midtonesDensity??0,r.imageProcessing.colorCurves.midtonesExposure=o.midtonesExposure??0,r.imageProcessing.colorCurves.midtonesSaturation=o.midtonesSaturation??0,r.imageProcessing.colorCurves.shadowsHue=o.shadowsHue??30,r.imageProcessing.colorCurves.shadowsDensity=o.shadowsDensity??0,r.imageProcessing.colorCurves.shadowsExposure=o.shadowsExposure??0,r.imageProcessing.colorCurves.shadowsSaturation=o.shadowsSaturation??0)}return r.bloomEnabled=o.bloomEnabled,r.bloomThreshold=o.bloomThreshold,r.bloomWeight=o.bloomWeight,r.bloomScale=o.bloomScale,r.bloomKernel=o.bloomKernel,r.sharpenEnabled=o.sharpenEnabled,r.sharpen.edgeAmount=o.sharpenEdgeAmount,r.sharpen.colorAmount=o.sharpenColorAmount,r.grainEnabled=o.grainEnabled,r.grain.intensity=o.grainIntensity,r.grain.animated=o.grainAnimated,r.depthOfFieldEnabled=o.depthOfFieldEnabled,r.depthOfFieldBlurLevel=o.depthOfFieldBlurLevel,r.depthOfField.lensSize=o.lensSize,r.depthOfField.fStop=o.fStop,r.depthOfField.focusDistance=o.focusDistance,r.depthOfField.focalLength=o.focalLength,r.chromaticAberrationEnabled=o.chromaticAberrationEnabled??!1,r.chromaticAberration.aberrationAmount=o.aberrationAmount??10,r.chromaticAberration.radialIntensity=o.radialIntensity??1,r.chromaticAberration.direction=de.Vector2.FromArray(o.direction??[0,0]),r.chromaticAberration.centerPosition=de.Vector2.FromArray(o.centerPosition??[0,0]),r.glowLayerEnabled=o.glowLayerEnabled??!1,r.glowLayer&&(r.glowLayer.intensity=o.glowLayerIntensity??1,r.glowLayer.blurKernelSize=o.glowLayerBlurKernelSize??32),r}i(Se,"parseDefaultRenderingPipeline");function Ye(e,t){(Array.isArray(t)?t:[]).forEach(n=>{let r=e.getCameraById(n.cameraId);r&&(n.ssao2RenderingPipeline&&V.set(r,n.ssao2RenderingPipeline),n.vlsPostProcess&&w.set(r,n.vlsPostProcess),n.ssrRenderingPipeline&&N.set(r,n.ssrRenderingPipeline),n.motionBlurPostProcess&&B.set(r,n.motionBlurPostProcess),n.defaultRenderingPipeline&&L.set(r,n.defaultRenderingPipeline))})}i(Ye,"applyRenderingConfigurations");function Jr(e){V.set(e,ce()),w.set(e,re()),N.set(e,se()),B.set(e,ge()),L.set(e,he())}i(Jr,"saveRenderingConfigurationForCamera");function He(e,t){le(),ne(e.getScene()),ie(),pe(),ye();let o=V.get(e);o&&me(e.getScene(),e,o);let n=w.get(e);n&&te(e.getScene(),n);let r=N.get(e);r&&ae(e.getScene(),e,r);let l=B.get(e);l&&fe(e.getScene(),e,l);let s=L.get(e);s&&Se(e.getScene(),e,s,t)}i(He,"applyRenderingConfigurationForCamera");var We=require("babylonjs"),$e=require("babylonjs");function be(e){e.lights.forEach(t=>{let o=t.getShadowGenerator()?.getShadowMap();o&&(o.renderListPredicate=n=>We.Vector3.Distance(n.getAbsolutePosition(),t.getAbsolutePosition())<=t.range)})}i(be,"configureShadowMapRenderListPredicate");async function Pe(e){e.executeWhenReady(()=>{e.lights.forEach(t=>{let o=t.getShadowGenerator()?.getShadowMap();o&&(o.refreshRate=t.metadata?.refreshRate??$e.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}i(Pe,"configureShadowMapRefreshRate");var Ce=require("babylonjs"),$=require("babylonjs"),Ro=(0,$.GetParser)(Ce.SceneComponentConstants.NAME_AUDIO);(0,$.AddParser)(Ce.SceneComponentConstants.NAME_AUDIO,(e,t,o,n)=>{Ro?.(e,t,o,n),e.sounds?.forEach(r=>{let l=o.sounds?.find(s=>s.name===r.name);l&&(l.id=r.id,l.uniqueId=r.uniqueId)})});function D(e){let t=1;for(;t<=e;)t<<=1;return t>>1}i(D,"getPowerOfTwoUntil");var Ie=require("babylonjs"),Q=Ie.SerializationHelper._TextureParser;Ie.SerializationHelper._TextureParser=(e,t,o)=>{if(t.loadingQuality==="high"||!e.metadata?.baseSize)return Q(e,t,o);let n=e.metadata.baseSize.width,r=e.metadata.baseSize.height,l=n===D(n)||r===D(r),s="";switch(t.loadingQuality){case"medium":let h=n*.66>>0,f=r*.66>>0;l&&(h=D(h),f=D(f)),s=`_${h}_${f}`;break;case"low":let p=n*.33>>0,g=r*.33>>0;l&&(p=D(p),g=D(g)),s=`_${p}_${g}`;break}let c=e.name;if(!c||!s)return Q(e,t,o);let u=c.split("/"),y=u.pop();if(!y)return Q(e,t,o);let P=y.split(".").pop(),O=`${y.replace(`.${P}`,"")}${s}.${P}`;return u.push(O),e.name=u.join("/"),Q(e,t,o)};var Qe=require("babylonjs"),Ue=require("babylonjs"),Ze=require("babylonjs");async function Oo(e,t,o,n,r){o.loadingQuality=r?.quality??"high",await(0,Ue.AppendSceneAsync)(`${e}${t}`,o,{pluginExtension:".babylon",onProgress:i(s=>{let c=Math.min(s.loaded/s.total*.5);r?.onProgress?.(c)},"onProgress")}),Ze.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&o.meshes.forEach(s=>T(s)&&s._checkDelayState());let l=o.getWaitingItemsCount();for(;!o.isReady()||o.getWaitingItemsCount()>0;){await new Promise(c=>setTimeout(c,150));let s=l-o.getWaitingItemsCount();r?.onProgress?.(.5+s/l*.5)}r?.onProgress?.(1),be(o),Pe(o),o.metadata?.rendering&&(Ye(o,o.metadata.rendering),o.activeCamera&&He(o.activeCamera,e)),o.metadata?.physicsGravity&&o.getPhysicsEngine()?.setGravity(Qe.Vector3.FromArray(o.metadata?.physicsGravity)),M(o,o,n,e),o.transformNodes.forEach(s=>{M(o,s,n,e)}),o.meshes.forEach(s=>{ve(s),M(o,s,n,e)}),o.lights.forEach(s=>{M(o,s,n,e)}),o.cameras.forEach(s=>{M(o,s,n,e)})}i(Oo,"loadScene");function Fo(e){e.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}i(Fo,"configureEngineToUseCompressedTextures");var A=require("babylonjs");function K(e){if(!isNaN(parseFloat(e))&&isFinite(e))return A.Animation.ANIMATIONTYPE_FLOAT;switch(e?.getClassName?.()){case"Vector2":return A.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return A.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return A.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return A.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return A.Animation.ANIMATIONTYPE_COLOR4;case"Size":return A.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return A.Animation.ANIMATIONTYPE_MATRIX}return null}i(K,"getAnimationTypeForObject");function Mo(e){return function(t,o){let n=t.constructor;n._NodesFromScene??=[],n._NodesFromScene.push({propertyKey:o,nodeName:e})}}i(Mo,"nodeFromScene");function wo(e,t=!1){return function(o,n){let r=o.constructor;r._NodesFromDescendants??=[],r._NodesFromDescendants.push({propertyKey:n,nodeName:e,directDescendantsOnly:t})}}i(wo,"nodeFromDescendants");function No(e){return function(t,o){let n=t.constructor;n._AnimationGroups??=[],n._AnimationGroups.push({animationGroupName:e,propertyKey:o})}}i(No,"animationGroupFromScene");function Vo(e,t){return function(o,n){let r=o.constructor;r._GuiFromAsset??=[],r._GuiFromAsset.push({propertyKey:n,pathInAssets:e,onGuiCreated:t})}}i(Vo,"guiFromAsset");function Bo(e){return function(t,o){let n=t.constructor;n._SoundsFromScene??=[],n._SoundsFromScene.push({propertyKey:o,soundName:e})}}i(Bo,"soundFromScene");function Lo(e){return function(t,o){let n=t.constructor;n._ParticleSystemsFromScene??=[],n._ParticleSystemsFromScene.push({propertyKey:o,particleSystemName:e})}}i(Lo,"particleSystemFromScene");function _o(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"boolean"}})}}i(_o,"visibleAsBoolean");function Go(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"number"}})}}i(Go,"visibleAsNumber");function Ko(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"vector2"}})}}i(Ko,"visibleAsVector2");function ko(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"vector3"}})}}i(ko,"visibleAsVector3");function zo(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"color3"}})}}i(zo,"visibleAsColor3");function jo(e,t){return function(o,n){let r=o.constructor;r._VisibleInInspector??=[],r._VisibleInInspector.push({label:e,propertyKey:n,configuration:{...t,type:"color4"}})}}i(jo,"visibleAsColor4");function Yo(e,t,o){return function(n,r){let l=n.constructor;l._VisibleInInspector??=[],l._VisibleInInspector.push({label:t,propertyKey:r,configuration:{...o,entityType:e,type:"entity"}})}}i(Yo,"visibleAsEntity");var U=require("babylonjs");function qe(e,t){let o;switch(e){case U.Animation.ANIMATIONTYPE_FLOAT:o=t.value;break;default:o=t.value.clone();break}return{value:o,frame:t.frame,interpolation:t.interpolation,inTangent:e===U.Animation.ANIMATIONTYPE_FLOAT?t.inTangent:t.inTangent?.clone(),outTangent:e===U.Animation.ANIMATIONTYPE_FLOAT?t.outTangent:t.outTangent?.clone()}}i(qe,"cloneKey");function Z(e,t){let o=t.split("."),n=e;for(let r=0;r<o.length;++r)n=n[o[r]];return n}i(Z,"getPropertyValue");var v=require("babylonjs"),q=require("babylonjs"),I=require("babylonjs");function Ho(e,t){return{name:e.name,framesPerSecond:e.framesPerSecond,outputFramesPerSecond:e.outputFramesPerSecond,tracks:e.tracks.map(o=>{let n=null,r=null;if(o.node?(n=t.getNodeById(o.node),n||(n=t.particleSystems?.find(s=>s.id===o.node)??null)):o.defaultRenderingPipeline&&(n=G()),o.propertyPath){let s=Z(n,o.propertyPath);r=K(s)}let l=null;return o.sound&&(l=Y(o.sound,t)),{node:n,sound:l,propertyPath:o.propertyPath,defaultRenderingPipeline:o.defaultRenderingPipeline,animationGroup:o.animationGroup?t.getAnimationGroupByName(o.animationGroup):null,animationGroups:o.animationGroups,sounds:o.sounds,keyFrameEvents:o.keyFrameEvents?.map(s=>{let c={...s};switch(s.data?.type){case"set-enabled":c.data={type:"set-enabled",value:s.data.value,node:t.getNodeById(s.data.node)};break;case"apply-impulse":c.data={type:"apply-impulse",radius:s.data.radius,mesh:t.getMeshById(s.data.mesh),force:I.Vector3.FromArray(s.data.force),contactPoint:I.Vector3.FromArray(s.data.contactPoint)};break}return c}),keyFrameAnimations:n&&r!==null&&o.keyFrameAnimations?.map(s=>{let c=s.type==="key"?s:null;if(c)return{...c,value:C(c.value,r),inTangent:C(c.inTangent,r),outTangent:C(c.outTangent,r)};let u=s.type==="cut"?s:null;if(u)return{...u,key1:{...u.key1,value:C(u.key1.value,r),inTangent:C(u.key1.inTangent,r),outTangent:C(u.key1.outTangent,r)},key2:{...u.key2,value:C(u.key2.value,r),inTangent:C(u.key2.inTangent,r),outTangent:C(u.key2.outTangent,r)}};throw new Error(`Unknown key frame type: ${s.type}`)})}})}}i(Ho,"parseCinematic");function C(e,t){if(e===null)return null;if(e!==void 0)switch(t){case v.Animation.ANIMATIONTYPE_FLOAT:return e;case v.Animation.ANIMATIONTYPE_VECTOR2:return I.Vector2.FromArray(e);case v.Animation.ANIMATIONTYPE_VECTOR3:return I.Vector3.FromArray(e);case v.Animation.ANIMATIONTYPE_QUATERNION:return I.Quaternion.FromArray(e);case v.Animation.ANIMATIONTYPE_COLOR3:return q.Color3.FromArray(e);case v.Animation.ANIMATIONTYPE_COLOR4:return q.Color4.FromArray(e);case v.Animation.ANIMATIONTYPE_MATRIX:return I.Matrix.FromArray(e)}}i(C,"parseCinematicKeyValue");function Xe(e){e.node?.setEnabled(e.value)}i(Xe,"handleSetEnabledEvent");var xe=require("babylonjs"),Je=xe.Vector3.Zero();function eo(e,t){let o=t.mesh?[t.mesh]:e.meshes.filter(n=>n.physicsAggregate);t.radius&&(o=o.filter(n=>{let r=n.getBoundingInfo().boundingBox.centerWorld;return xe.Vector3.Distance(r,t.contactPoint)<=t.radius})),o.forEach(n=>{if(n.physicsAggregate?.body){let r=t.contactPoint.subtract(n.getBoundingInfo().boundingBox.centerWorld);r.multiplyInPlace(t.force),n.physicsAggregate.body.setLinearVelocity(Je),n.physicsAggregate.body.setAngularVelocity(Je),n.physicsAggregate.body.applyImpulse(r.negateInPlace(),t.contactPoint)}})}i(eo,"handleApplyImpulseEvent");var oo=require("babylonjs"),E=require("babylonjs"),k=require("babylonjs"),no=require("babylonjs");function Wo(e,t,o){let n=new no.AnimationGroup(e.name,t);return e.tracks.forEach(r=>{let l=r.animationGroup;l&&r.animationGroups?.forEach(h=>{l.targetedAnimations.forEach(f=>{let p=null;e:{let x=n.targetedAnimations.filter(z=>z.target===f.target);if(x.length){let z=x.find(ro=>ro.animation.targetProperty===f.animation.targetProperty);if(z){p=z.animation;break e}}p=f.animation.clone(),p.setKeys([]),p.name=oo.Tools.RandomId(),p.framePerSecond=e.framesPerSecond}let g=p.getKeys(),F=f.animation.getKeys(),X=h.speed,Ae=e.framesPerSecond/f.animation.framePerSecond/X;F.forEach(x=>{x.frame>=h.startFrame&&x.frame<=h.endFrame&&g.push({...qe(f.animation.dataType,x),frame:h.frame+x.frame*Ae})}),p.setKeys(g),n.addTargetedAnimation(p,f.target)})});let s=r.sound,c=s?.getAudioBuffer();if(!o?.ignoreSounds&&s&&c&&r.sounds?.length){let h={dummy:0},f=new E.Animation(s.name,"dummy",60,E.Animation.ANIMATIONTYPE_FLOAT,E.Animation.ANIMATIONLOOPMODE_CYCLE,!1),p=0;r.sounds?.forEach(g=>{let F=g.endFrame-g.startFrame;p=Math.max(p,g.frame+F),f.addEvent(new k.AnimationEvent(g.frame,X=>{let x=(X-g.frame+g.startFrame)/e.framesPerSecond;s.play(0,x)},!1)),f.addEvent(new k.AnimationEvent(g.frame+F,()=>{s.stop()}))}),f.setKeys([{frame:0,value:0},{frame:p,value:p}]),n.addTargetedAnimation(f,h)}if(r.keyFrameEvents){let h={dummy:0},f=new E.Animation("events","dummy",60,E.Animation.ANIMATIONTYPE_FLOAT,E.Animation.ANIMATIONLOOPMODE_CYCLE,!1),p=0;r.keyFrameEvents?.forEach(g=>{p=Math.max(p,g.frame),f.addEvent(new k.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"set-enabled":Xe(g.data);break;case"apply-impulse":eo(t,g.data);break}}))}),f.setKeys([{frame:0,value:0},{frame:p,value:p}]),n.addTargetedAnimation(f,h)}let u=r.defaultRenderingPipeline?G():r.node;if(!u||!r.propertyPath||!r.keyFrameAnimations)return;let y=Z(u,r.propertyPath),P=K(y);if(P===null)return;let R=new E.Animation(r.propertyPath,r.propertyPath,60,P,E.Animation.ANIMATIONLOOPMODE_CYCLE,!1),O=[];r.keyFrameAnimations?.forEach(h=>{let f=h.type==="key"?h:null;if(f)return O.push(f);let p=h.type==="cut"?h:null;p&&(O.push(p.key1),O.push(p.key2),oe(u)&&r.propertyPath==="position"&&R.addEvent(new k.AnimationEvent(p.key1.frame,()=>{let g=ue();if(!g)return;let F=g.motionStrength;g.motionStrength=0,requestAnimationFrame(()=>{g.motionStrength=F})})))}),R.setKeys(O),n.addTargetedAnimation(R,u)}),n.normalize(),n}i(Wo,"generateCinematicAnimationGroup");function $o(e){return e.type==="key"}i($o,"isCinematicKey");function Qo(e){return e.type==="cut"}i(Qo,"isCinematicKeyCut");function Uo(e){return e.type==="event"}i(Uo,"isCinematicKeyEvent");function Zo(e){return e.type==="group"}i(Zo,"isCinematicGroup");function qo(e){return e.type==="sound"}i(qo,"isCinematicSound");0&&(module.exports={animationGroupFromScene,configureEngineToUseCompressedTextures,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createVLSPostProcess,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeVLSPostProcess,generateCinematicAnimationGroup,getAnimationTypeForObject,getDefaultRenderingPipeline,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getVLSPostProcess,guiFromAsset,isAbstractMesh,isArcRotateCamera,isBone,isCamera,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isDirectionalLight,isFreeCamera,isGroundMesh,isHemisphericLight,isInstancedMesh,isMesh,isPointLight,isSpotLight,isTexture,isTransformNode,loadScene,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseMotionBlurPostProcess,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseVLSPostProcess,particleSystemFromScene,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeVLSPostProcess,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setVLSPostProcessRef,soundFromScene,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsNumber,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations});
1
+ var H=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var ht=Object.prototype.hasOwnProperty;var i=(e,o)=>H(e,"name",{value:o,configurable:!0});var St=(e,o)=>{for(var t in o)H(e,t,{get:o[t],enumerable:!0})},Pt=(e,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of yt(o))!ht.call(e,n)&&n!==t&&H(e,n,{get:()=>o[n],enumerable:!(r=dt(o,n))||r.enumerable});return e};var bt=e=>Pt(H({},"__esModule",{value:!0}),e);var pr={};St(pr,{_applyScriptsForObject:()=>R,animationGroupFromScene:()=>Wt,configureEngineToUseCompressedTextures:()=>jt,configureShadowMapRefreshRate:()=>Ae,configureShadowMapRenderListPredicate:()=>xe,createDefaultRenderingPipeline:()=>Je,createMotionBlurPostProcess:()=>$e,createSSAO2RenderingPipeline:()=>We,createSSRRenderingPipeline:()=>He,createVLSPostProcess:()=>ze,defaultPipelineCameraConfigurations:()=>B,disposeDefaultRenderingPipeline:()=>be,disposeMotionBlurPostProcess:()=>ye,disposeSSAO2RenderingPipeline:()=>pe,disposeSSRRenderingPipeline:()=>ce,disposeVLSPostProcess:()=>se,generateCinematicAnimationGroup:()=>sr,getAllScriptsByClassForObject:()=>Le,getAnimationTypeForObject:()=>k,getDefaultRenderingPipeline:()=>K,getMotionBlurPostProcess:()=>de,getPowerOfTwoUntil:()=>D,getSSAO2RenderingPipeline:()=>Lt,getSSRRenderingPipeline:()=>Nt,getScriptByClassForObject:()=>Ft,getVLSPostProcess:()=>Mt,guiFromAsset:()=>Ut,isAbstractMesh:()=>Re,isAnyParticleSystem:()=>ie,isArcRotateCamera:()=>At,isBone:()=>Ct,isCamera:()=>Y,isCinematicGroup:()=>mr,isCinematicKey:()=>ar,isCinematicKeyCut:()=>lr,isCinematicKeyEvent:()=>cr,isCinematicSound:()=>ur,isDirectionalLight:()=>Et,isFreeCamera:()=>xt,isGPUParticleSystem:()=>Ot,isGroundMesh:()=>It,isHemisphericLight:()=>vt,isInstancedMesh:()=>te,isLight:()=>Fe,isMesh:()=>E,isNode:()=>ne,isParticleSystem:()=>Rt,isPointLight:()=>Tt,isScene:()=>oe,isSpotLight:()=>Dt,isTexture:()=>re,isTransformNode:()=>Oe,loadMaterialFromFile:()=>zt,loadScene:()=>kt,motionBlurPostProcessCameraConfigurations:()=>L,nodeFromDescendants:()=>Yt,nodeFromScene:()=>Ht,parseCinematic:()=>ir,parseCinematicKeyValue:()=>C,parseDefaultRenderingPipeline:()=>Ie,parseMotionBlurPostProcess:()=>Se,parseSSAO2RenderingPipeline:()=>fe,parseSSRRenderingPipeline:()=>ue,parseVLSPostProcess:()=>le,particleSystemFromScene:()=>Qt,registerScriptInstance:()=>Ve,serializeDefaultRenderingPipeline:()=>Ce,serializeMotionBlurPostProcess:()=>he,serializeSSAO2RenderingPipeline:()=>ge,serializeSSRRenderingPipeline:()=>me,serializeVLSPostProcess:()=>ae,setDefaultRenderingPipelineRef:()=>Gt,setMotionBlurPostProcessRef:()=>_t,setSSAO2RenderingPipelineRef:()=>Bt,setSSRRenderingPipelineRef:()=>Vt,setVLSPostProcessRef:()=>wt,soundFromScene:()=>$t,ssaoRenderingPipelineCameraConfigurations:()=>V,ssrRenderingPipelineCameraConfigurations:()=>N,visibleAsBoolean:()=>Zt,visibleAsColor3:()=>er,visibleAsColor4:()=>tr,visibleAsEntity:()=>rr,visibleAsKeyMap:()=>or,visibleAsNumber:()=>qt,visibleAsTexture:()=>nr,visibleAsVector2:()=>Xt,visibleAsVector3:()=>Jt,vlsPostProcessCameraConfigurations:()=>w});module.exports=bt(pr);function Re(e){switch(e.getClassName?.()){case"Mesh":case"LineMesh":case"GroundMesh":case"InstancedMesh":return!0}return!1}i(Re,"isAbstractMesh");function E(e){switch(e.getClassName?.()){case"Mesh":case"GroundMesh":return!0}return!1}i(E,"isMesh");function te(e){return e.getClassName?.()==="InstancedMesh"}i(te,"isInstancedMesh");function Ct(e){return e.getClassName?.()==="Bone"}i(Ct,"isBone");function It(e){return e.getClassName?.()==="GroundMesh"}i(It,"isGroundMesh");function Oe(e){return e.getClassName?.()==="TransformNode"}i(Oe,"isTransformNode");function re(e){return e?.getClassName?.()==="Texture"}i(re,"isTexture");function Y(e){switch(e.getClassName?.()){case"Camera":case"FreeCamera":case"TargetCamera":case"EditorCamera":case"ArcRotateCamera":case"UniversalCamera":return!0}return!1}i(Y,"isCamera");function xt(e){switch(e.getClassName?.()){case"FreeCamera":case"UniversalCamera":return!0}return!1}i(xt,"isFreeCamera");function At(e){return e.getClassName?.()==="ArcRotateCamera"}i(At,"isArcRotateCamera");function Tt(e){return e.getClassName?.()==="PointLight"}i(Tt,"isPointLight");function Et(e){return e.getClassName?.()==="DirectionalLight"}i(Et,"isDirectionalLight");function Dt(e){return e.getClassName?.()==="SpotLight"}i(Dt,"isSpotLight");function vt(e){return e.getClassName?.()==="HemisphericLight"}i(vt,"isHemisphericLight");function Fe(e){switch(e.getClassName?.()){case"Light":case"PointLight":case"SpotLight":case"DirectionalLight":case"HemisphericLight":return!0}return!1}i(Fe,"isLight");function ne(e){return Re(e)||Oe(e)||Fe(e)||Y(e)}i(ne,"isNode");function oe(e){return e.getClassName?.()==="Scene"}i(oe,"isScene");function Rt(e){return e.getClassName?.()==="ParticleSystem"}i(Rt,"isParticleSystem");function Ot(e){return e.getClassName?.()==="GPUParticleSystem"}i(Ot,"isGPUParticleSystem");function ie(e){switch(e.getClassName?.()){case"ParticleSystem":case"GPUParticleSystem":return!0}return!1}i(ie,"isAnyParticleSystem");function W(e,o){let t=o.soundTracks??[];t.length||t.push(o.mainSoundTrack);for(let r=0,n=t.length;r<n;r++){let l=t[r].soundCollection.find(s=>s.id===e);if(l)return l}return null}i(W,"getSoundById");var U=require("babylonjs"),Me=require("babylonjs"),$=require("babylonjs"),we=require("babylonjs-gui");function Ne(e,o,t,r,n){let l=r.constructor;l&&(l._NodesFromScene?.forEach(s=>{r[s.propertyKey.toString()]=e.getNodeByName(s.nodeName)}),l._NodesFromDescendants?.forEach(s=>{let c=o.getDescendants?.(s.directDescendantsOnly,u=>u.name===s.nodeName)[0];r[s.propertyKey.toString()]=c??null}),l._AnimationGroups?.forEach(s=>{r[s.propertyKey.toString()]=e.getAnimationGroupByName(s.animationGroupName)}),l._SoundsFromScene?.forEach(s=>{let c=e.getSoundByName?.(s.soundName);r[s.propertyKey.toString()]=c??null}),l._GuiFromAsset?.forEach(async s=>{let c=`${n}assets/${s.pathInAssets}`;try{let y=await(await fetch(c)).json(),b=we.AdvancedDynamicTexture.CreateFullscreenUI(y.name,!0,e);b.parseSerializedObject(y.content,!1),r[s.propertyKey.toString()]=b,s.onGuiCreated?.(r,b)}catch(u){throw console.error(`Failed to load GUI from asset: ${c}`),u}}),l._ParticleSystemsFromScene?.forEach(s=>{let c=e.particleSystems?.find(u=>u.name===s.particleSystemName);r[s.propertyKey.toString()]=c}),l._VisibleInInspector?.forEach(s=>{let c=s.propertyKey.toString(),u=t.values;if(u.hasOwnProperty(c)&&u[c].hasOwnProperty("value")){let y=u[c].value;switch(s.configuration.type){case"number":case"boolean":case"keymap":r[c]=y;break;case"vector2":r[c]=$.Vector2.FromArray(y);break;case"vector3":r[c]=$.Vector3.FromArray(y);break;case"color3":r[c]=U.Color3.FromArray(y);break;case"color4":r[c]=U.Color4.FromArray(y);break;case"entity":switch(s.configuration.entityType){case"node":r[c]=e.getNodeById(y)??null;break;case"animationGroup":r[c]=e.getAnimationGroupByName(y)??null;break;case"sound":r[c]=W(y,e);break;case"particleSystem":r[c]=e.particleSystems?.find(O=>O.id===y)??null;break}break;case"texture":y&&(r[c]=Me.Texture.Parse(y,e,n));break}}}))}i(Ne,"applyDecorators");function R(e,o,t,r){o.metadata&&(o.metadata.scripts?.forEach(n=>{if(!n.enabled)return;let l=t[n.key];if(l)if(l.default){let s=new l.default(o);Ve(o,s,n.key),Ne(e,o,n,s,r),s.onStart&&e.onBeforeRenderObservable.addOnce(()=>s.onStart()),s.onUpdate&&e.onBeforeRenderObservable.add(()=>s.onUpdate())}else l.onStart&&e.onBeforeRenderObservable.addOnce(()=>l.onStart(o)),l.onUpdate&&e.onBeforeRenderObservable.add(()=>l.onUpdate(o))}),o.metadata.scripts=void 0)}i(R,"_applyScriptsForObject");var _=new Map;function Ve(e,o,t){let r={key:t,instance:o};_.has(e)?_.get(e).push(r):_.set(e,[r]),(ne(e)||ie(e)||oe(e))&&e.onDisposeObservable.addOnce(()=>{_.delete(e)})}i(Ve,"registerScriptInstance");function Le(e,o){return _.get(e)?.filter(n=>n.instance.constructor===o)?.map(n=>n.instance)??null}i(Le,"getAllScriptsByClassForObject");function Ft(e,o){return Le(e,o)?.[0]??null}i(Ft,"getScriptByClassForObject");var G=require("babylonjs"),Be=require("babylonjs");function _e(e){let o=e.metadata?.physicsAggregate;if(!o)return;let t;E(e)?t=e:te(e)&&(t=e.sourceMesh);let r=new Be.PhysicsAggregate(e,o.shape.type,{mesh:t,mass:o.massProperties.mass});r.body.setMassProperties({mass:o.massProperties.mass,inertia:o.massProperties.inertia?G.Vector3.FromArray(o.massProperties.inertia):void 0,centerOfMass:o.massProperties.centerOfMass?G.Vector3.FromArray(o.massProperties.centerOfMass):void 0,inertiaOrientation:o.massProperties.inertiaOrientation?G.Quaternion.FromArray(o.massProperties.inertiaOrientation):void 0}),r.shape.density=o.shape.density,r.body.setMotionType(o.body.motionType),r.shape.material=o.material,e.physicsAggregate=r,e.metadata.physicsAggregate=void 0}i(_e,"configurePhysicsAggregate");var Ge=require("babylonjs"),Ke=require("babylonjs"),ke=require("babylonjs"),S=null,w=new Map;function Mt(){return S}i(Mt,"getVLSPostProcess");function wt(e){S=e}i(wt,"setVLSPostProcessRef");function se(e){S&&e.activeCamera&&(S.dispose(e.activeCamera),S=null)}i(se,"disposeVLSPostProcess");function ze(e,o){return o??=e.meshes.find(t=>E(t)),S=new ke.VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess",1,e.activeCamera,o,100,Ke.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1),S}i(ze,"createVLSPostProcess");function ae(){return S?{meshId:S.mesh?.id,exposure:S.exposure,decay:S.decay,weight:S.weight,density:S.density,invert:S.invert,useCustomMeshPosition:S.useCustomMeshPosition,customMeshPosition:S.customMeshPosition.asArray()}:null}i(ae,"serializeVLSPostProcess");function le(e,o){let t=null;if(o.meshId){let n=e.getMeshById(o.meshId);n&&E(n)&&(t=n)}let r=ze(e,t);return r.exposure=o.exposure,r.decay=o.decay,r.weight=o.weight,r.density=o.density,r.invert=o.invert,r.useCustomMeshPosition=o.useCustomMeshPosition,r.customMeshPosition.copyFrom(Ge.Vector3.FromArray(o.customMeshPosition)),r}i(le,"parseVLSPostProcess");var je=require("babylonjs"),m=null,N=new Map;function Nt(){return m}i(Nt,"getSSRRenderingPipeline");function Vt(e){m=e}i(Vt,"setSSRRenderingPipelineRef");function ce(){m&&(m.dispose(),m=null)}i(ce,"disposeSSRRenderingPipeline");function He(e,o){return m=new je.SSRRenderingPipeline("SSRRenderingPipeline",e,[o]),m.samples=4,m}i(He,"createSSRRenderingPipeline");function me(){return m?{samples:m.samples,step:m.step,thickness:m.thickness,strength:m.strength,reflectionSpecularFalloffExponent:m.reflectionSpecularFalloffExponent,maxSteps:m.maxSteps,maxDistance:m.maxDistance,roughnessFactor:m.roughnessFactor,reflectivityThreshold:m.reflectivityThreshold,blurDispersionStrehgth:m.blurDispersionStrength,clipToFrustum:m.clipToFrustum,enableSmoothReflections:m.enableSmoothReflections,enableAutomaticThicknessComputation:m.enableAutomaticThicknessComputation,attenuateFacingCamera:m.attenuateFacingCamera,attenuateScreenBorders:m.attenuateScreenBorders,attenuateIntersectionDistance:m.attenuateIntersectionDistance,attenuateBackfaceReflection:m.attenuateBackfaceReflection,blurDownsample:m.blurDownsample,selfCollisionNumSkip:m.selfCollisionNumSkip,ssrDownsample:m.ssrDownsample,backfaceDepthTextureDownsample:m.backfaceDepthTextureDownsample}:null}i(me,"serializeSSRRenderingPipeline");function ue(e,o,t){if(m)return m;let r=He(e,o);return r.samples=t.samples,r.step=t.step,r.thickness=t.thickness,r.strength=t.strength,r.reflectionSpecularFalloffExponent=t.reflectionSpecularFalloffExponent,r.maxSteps=t.maxSteps,r.maxDistance=t.maxDistance,r.roughnessFactor=t.roughnessFactor,r.reflectivityThreshold=t.reflectivityThreshold,r.blurDispersionStrength=t.blurDispersionStrehgth,r.clipToFrustum=t.clipToFrustum,r.enableSmoothReflections=t.enableSmoothReflections,r.enableAutomaticThicknessComputation=t.enableAutomaticThicknessComputation,r.attenuateFacingCamera=t.attenuateFacingCamera,r.attenuateScreenBorders=t.attenuateScreenBorders,r.attenuateIntersectionDistance=t.attenuateIntersectionDistance,r.attenuateBackfaceReflection=t.attenuateBackfaceReflection,r.blurDownsample=t.blurDownsample,r.selfCollisionNumSkip=t.selfCollisionNumSkip,r.ssrDownsample=t.ssrDownsample,r.backfaceDepthTextureDownsample=t.backfaceDepthTextureDownsample,r}i(ue,"parseSSRRenderingPipeline");var Ye=require("babylonjs"),d=null,V=new Map;function Lt(){return d}i(Lt,"getSSAO2RenderingPipeline");function Bt(e){d=e}i(Bt,"setSSAO2RenderingPipelineRef");function pe(){d&&(d.dispose(),d=null)}i(pe,"disposeSSAO2RenderingPipeline");function We(e,o){return d=new Ye.SSAO2RenderingPipeline("SSAO2RenderingPipeline",e,1,[o]),d.samples=4,d}i(We,"createSSAO2RenderingPipeline");function ge(){return d?{radius:d.radius,totalStrength:d.totalStrength,samples:d.samples,maxZ:d.maxZ,minZAspect:d.minZAspect,epsilon:d.epsilon,textureSamples:d.textureSamples,bypassBlur:d.bypassBlur,bilateralSamples:d.bilateralSamples,bilateralSoften:d.bilateralSoften,bilateralTolerance:d.bilateralTolerance,expensiveBlur:d.expensiveBlur}:null}i(ge,"serializeSSAO2RenderingPipeline");function fe(e,o,t){if(d)return d;let r=We(e,o);return r.radius=t.radius,r.totalStrength=t.totalStrength,r.samples=t.samples,r.maxZ=t.maxZ,r.minZAspect=t.minZAspect,r.epsilon=t.epsilon,r.textureSamples=t.textureSamples,r.bypassBlur=t.bypassBlur,r.bilateralSamples=t.bilateralSamples,r.bilateralSoften=t.bilateralSoften,r.bilateralTolerance=t.bilateralTolerance,r.expensiveBlur=t.expensiveBlur,r}i(fe,"parseSSAO2RenderingPipeline");var Ue=require("babylonjs"),P=null,L=new Map;function de(){return P}i(de,"getMotionBlurPostProcess");function _t(e){P=e}i(_t,"setMotionBlurPostProcessRef");function ye(){P&&(P.dispose(),P=null)}i(ye,"disposeMotionBlurPostProcess");function $e(e,o){return P=new Ue.MotionBlurPostProcess("MotionBlurPostProcess",e,1,o),P.motionStrength=1,P.isObjectBased=!0,P}i($e,"createMotionBlurPostProcess");function he(){return P?{isObjectBased:P.isObjectBased,motionStrength:P.motionStrength,motionBlurSamples:P.motionBlurSamples}:null}i(he,"serializeMotionBlurPostProcess");function Se(e,o,t){if(P)return P;let r=$e(e,o);return r.isObjectBased=t.isObjectBased,r.motionStrength=t.motionStrength,r.motionBlurSamples=t.motionBlurSamples,r}i(Se,"parseMotionBlurPostProcess");var Qe=require("babylonjs"),Pe=require("babylonjs"),Ze=require("babylonjs"),qe=require("babylonjs"),Xe=require("babylonjs"),a=null,B=new Map;function K(){return a}i(K,"getDefaultRenderingPipeline");function Gt(e){a=e}i(Gt,"setDefaultRenderingPipelineRef");function be(){a&&(a.dispose(),a=null)}i(be,"disposeDefaultRenderingPipeline");function Je(e,o){return a=new Xe.DefaultRenderingPipeline("DefaultRenderingPipeline",!0,e,[o]),a.samples=4,a.depthOfField.lensSize=512,a.depthOfField.fStop=.25,a.depthOfField.focusDistance=55e3,a}i(Je,"createDefaultRenderingPipeline");function Ce(){return a?{samples:a.samples,fxaaEnabled:a.fxaaEnabled,imageProcessingEnabled:a.imageProcessingEnabled,exposure:a.imageProcessing?.exposure,contrast:a.imageProcessing?.contrast,fromLinearSpace:a.imageProcessing?.fromLinearSpace,toneMappingEnabled:a.imageProcessing?.toneMappingEnabled,toneMappingType:a.imageProcessing?.toneMappingType,ditheringEnabled:a.imageProcessing?.ditheringEnabled,ditheringIntensity:a.imageProcessing?.ditheringIntensity,bloomEnabled:a.bloomEnabled,bloomThreshold:a.bloomThreshold,bloomWeight:a.bloomWeight,bloomScale:a.bloomScale,bloomKernel:a.bloomKernel,sharpenEnabled:a.sharpenEnabled,sharpenEdgeAmount:a.sharpen.edgeAmount,sharpenColorAmount:a.sharpen.colorAmount,grainEnabled:a.grainEnabled,grainIntensity:a.grain.intensity,grainAnimated:a.grain.animated,depthOfFieldEnabled:a.depthOfFieldEnabled,depthOfFieldBlurLevel:a.depthOfFieldBlurLevel,lensSize:a.depthOfField.lensSize,fStop:a.depthOfField.fStop,focusDistance:a.depthOfField.focusDistance,focalLength:a.depthOfField.focalLength,vignetteEnabled:a.imageProcessing?.vignetteEnabled,vignetteColor:a.imageProcessing?.vignetteColor.asArray(),vignetteWeight:a.imageProcessing?.vignetteWeight,chromaticAberrationEnabled:a.chromaticAberrationEnabled,aberrationAmount:a.chromaticAberration.aberrationAmount,radialIntensity:a.chromaticAberration.radialIntensity,direction:a.chromaticAberration.direction.asArray(),centerPosition:a.chromaticAberration.centerPosition.asArray(),glowLayerEnabled:a.glowLayerEnabled,glowLayerIntensity:a.glowLayer?.intensity,glowLayerBlurKernelSize:a.glowLayer?.blurKernelSize,colorGradingEnabled:a.imageProcessing.colorGradingEnabled,colorGradingTexture:a.imageProcessing.colorGradingTexture?.serialize(),colorGradingWithGreenDepth:a.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth,colorCurvesEnabled:a.imageProcessing.colorCurvesEnabled,globalHue:a.imageProcessing.colorCurves?.globalHue,globalDensity:a.imageProcessing.colorCurves?.globalDensity,globalExposure:a.imageProcessing.colorCurves?.globalExposure,globalSaturation:a.imageProcessing.colorCurves?.globalSaturation,highlightsHue:a.imageProcessing.colorCurves?.highlightsHue,highlightsDensity:a.imageProcessing.colorCurves?.highlightsDensity,highlightsExposure:a.imageProcessing.colorCurves?.highlightsExposure,highlightsSaturation:a.imageProcessing.colorCurves?.highlightsSaturation,midtonesHue:a.imageProcessing.colorCurves?.midtonesHue,midtonesDensity:a.imageProcessing.colorCurves?.midtonesDensity,midtonesExposure:a.imageProcessing.colorCurves?.midtonesExposure,midtonesSaturation:a.imageProcessing.colorCurves?.midtonesSaturation,shadowsHue:a.imageProcessing.colorCurves?.shadowsHue,shadowsDensity:a.imageProcessing.colorCurves?.shadowsDensity,shadowsExposure:a.imageProcessing.colorCurves?.shadowsExposure,shadowsSaturation:a.imageProcessing.colorCurves?.shadowsSaturation}:null}i(Ce,"serializeDefaultRenderingPipeline");function Ie(e,o,t,r){if(a)return a;let n=Je(e,o);if(n.samples=t.samples,n.fxaaEnabled=t.fxaaEnabled,n.imageProcessingEnabled=t.imageProcessingEnabled,n.imageProcessing){if(n.imageProcessing.exposure=t.exposure,n.imageProcessing.contrast=t.contrast,n.imageProcessing.fromLinearSpace=t.fromLinearSpace,n.imageProcessing.toneMappingEnabled=t.toneMappingEnabled,n.imageProcessing.toneMappingType=t.toneMappingType,n.imageProcessing.ditheringEnabled=t.ditheringEnabled,n.imageProcessing.ditheringIntensity=t.ditheringIntensity,n.imageProcessing.vignetteEnabled=t.vignetteEnabled??!1,n.imageProcessing.vignetteColor=Qe.Color4.FromArray(t.vignetteColor??[0,0,0]),n.imageProcessing.vignetteWeight=t.vignetteWeight??.3,n.imageProcessing.colorGradingEnabled=t.colorGradingEnabled??!1,n.imageProcessing.imageProcessingConfiguration.colorGradingWithGreenDepth=t.colorGradingWithGreenDepth??!0,t.colorGradingTexture){let l=null;if(t.colorGradingTexture.customType==="BABYLON.ColorGradingTexture"){let s=r+t.colorGradingTexture.name;l=new qe.ColorGradingTexture(s,e),l.level=t.colorGradingTexture.level}else{let s=Ze.Texture.Parse(t.colorGradingTexture,e,r);re(s)&&(l=s)}n.imageProcessing.colorGradingTexture=l}n.imageProcessing.colorCurvesEnabled=t.colorCurvesEnabled??!1,n.imageProcessing.colorCurves&&(n.imageProcessing.colorCurves.globalHue=t.globalHue??30,n.imageProcessing.colorCurves.globalDensity=t.globalDensity??0,n.imageProcessing.colorCurves.globalExposure=t.globalExposure??0,n.imageProcessing.colorCurves.globalSaturation=t.globalSaturation??0,n.imageProcessing.colorCurves.highlightsHue=t.highlightsHue??30,n.imageProcessing.colorCurves.highlightsDensity=t.highlightsDensity??0,n.imageProcessing.colorCurves.highlightsExposure=t.highlightsExposure??0,n.imageProcessing.colorCurves.highlightsSaturation=t.highlightsSaturation??0,n.imageProcessing.colorCurves.midtonesHue=t.midtonesHue??30,n.imageProcessing.colorCurves.midtonesDensity=t.midtonesDensity??0,n.imageProcessing.colorCurves.midtonesExposure=t.midtonesExposure??0,n.imageProcessing.colorCurves.midtonesSaturation=t.midtonesSaturation??0,n.imageProcessing.colorCurves.shadowsHue=t.shadowsHue??30,n.imageProcessing.colorCurves.shadowsDensity=t.shadowsDensity??0,n.imageProcessing.colorCurves.shadowsExposure=t.shadowsExposure??0,n.imageProcessing.colorCurves.shadowsSaturation=t.shadowsSaturation??0)}return n.bloomEnabled=t.bloomEnabled,n.bloomThreshold=t.bloomThreshold,n.bloomWeight=t.bloomWeight,n.bloomScale=t.bloomScale,n.bloomKernel=t.bloomKernel,n.sharpenEnabled=t.sharpenEnabled,n.sharpen.edgeAmount=t.sharpenEdgeAmount,n.sharpen.colorAmount=t.sharpenColorAmount,n.grainEnabled=t.grainEnabled,n.grain.intensity=t.grainIntensity,n.grain.animated=t.grainAnimated,n.depthOfFieldEnabled=t.depthOfFieldEnabled,n.depthOfFieldBlurLevel=t.depthOfFieldBlurLevel,n.depthOfField.lensSize=t.lensSize,n.depthOfField.fStop=t.fStop,n.depthOfField.focusDistance=t.focusDistance,n.depthOfField.focalLength=t.focalLength,n.chromaticAberrationEnabled=t.chromaticAberrationEnabled??!1,n.chromaticAberration.aberrationAmount=t.aberrationAmount??10,n.chromaticAberration.radialIntensity=t.radialIntensity??1,n.chromaticAberration.direction=Pe.Vector2.FromArray(t.direction??[0,0]),n.chromaticAberration.centerPosition=Pe.Vector2.FromArray(t.centerPosition??[0,0]),n.glowLayerEnabled=t.glowLayerEnabled??!1,n.glowLayer&&(n.glowLayer.intensity=t.glowLayerIntensity??1,n.glowLayer.blurKernelSize=t.glowLayerBlurKernelSize??32),n}i(Ie,"parseDefaultRenderingPipeline");function et(e,o){(Array.isArray(o)?o:[]).forEach(r=>{let n=e.getCameraById(r.cameraId);n&&(r.ssao2RenderingPipeline&&V.set(n,r.ssao2RenderingPipeline),r.vlsPostProcess&&w.set(n,r.vlsPostProcess),r.ssrRenderingPipeline&&N.set(n,r.ssrRenderingPipeline),r.motionBlurPostProcess&&L.set(n,r.motionBlurPostProcess),r.defaultRenderingPipeline&&B.set(n,r.defaultRenderingPipeline))})}i(et,"applyRenderingConfigurations");function wo(e){V.set(e,ge()),w.set(e,ae()),N.set(e,me()),L.set(e,he()),B.set(e,Ce())}i(wo,"saveRenderingConfigurationForCamera");function tt(e,o){pe(),se(e.getScene()),ce(),ye(),be();let t=V.get(e);t&&fe(e.getScene(),e,t);let r=w.get(e);r&&le(e.getScene(),r);let n=N.get(e);n&&ue(e.getScene(),e,n);let l=L.get(e);l&&Se(e.getScene(),e,l);let s=B.get(e);s&&Ie(e.getScene(),e,s,o)}i(tt,"applyRenderingConfigurationForCamera");var rt=require("babylonjs"),nt=require("babylonjs");function xe(e){e.lights.forEach(o=>{let t=o.getShadowGenerator()?.getShadowMap();t&&(t.renderListPredicate=r=>rt.Vector3.Distance(r.getAbsolutePosition(),o.getAbsolutePosition())<=o.range)})}i(xe,"configureShadowMapRenderListPredicate");async function Ae(e){e.executeWhenReady(()=>{e.lights.forEach(o=>{let t=o.getShadowGenerator()?.getShadowMap();t&&(t.refreshRate=o.metadata?.refreshRate??nt.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME)})})}i(Ae,"configureShadowMapRefreshRate");var Te=require("babylonjs"),Q=require("babylonjs"),Kt=(0,Q.GetParser)(Te.SceneComponentConstants.NAME_AUDIO);(0,Q.AddParser)(Te.SceneComponentConstants.NAME_AUDIO,(e,o,t,r)=>{Kt?.(e,o,t,r),e.sounds?.forEach(n=>{let l=t.sounds?.find(s=>s.name===n.name);l&&(l.id=n.id,l.uniqueId=n.uniqueId)})});function D(e){let o=1;for(;o<=e;)o<<=1;return o>>1}i(D,"getPowerOfTwoUntil");var Ee=require("babylonjs"),Z=Ee.SerializationHelper._TextureParser;Ee.SerializationHelper._TextureParser=(e,o,t)=>{if(o.loadingQuality==="high"||!e.metadata?.baseSize)return Z(e,o,t);let r=e.metadata.baseSize.width,n=e.metadata.baseSize.height,l=r===D(r)||n===D(n),s="";switch(o.loadingQuality){case"medium":let h=r*.66>>0,f=n*.66>>0;l&&(h=D(h),f=D(f)),s=`_${h}_${f}`;break;case"low":let p=r*.33>>0,g=n*.33>>0;l&&(p=D(p),g=D(g)),s=`_${p}_${g}`;break}let c=e.name;if(!c||!s)return Z(e,o,t);let u=c.split("/"),y=u.pop();if(!y)return Z(e,o,t);let b=y.split(".").pop(),F=`${y.replace(`.${b}`,"")}${s}.${b}`;return u.push(F),e.name=u.join("/"),Z(e,o,t)};var ot=require("babylonjs"),it=require("babylonjs"),st=require("babylonjs");async function kt(e,o,t,r,n){t.loadingQuality=n?.quality??"high",await(0,it.AppendSceneAsync)(`${e}${o}`,t,{pluginExtension:".babylon",onProgress:i(s=>{let c=Math.min(s.loaded/s.total*.5);n?.onProgress?.(c)},"onProgress")}),st.SceneLoaderFlags.ForceFullSceneLoadingForIncremental&&t.meshes.forEach(s=>E(s)&&s._checkDelayState());let l=t.getWaitingItemsCount();for(;!t.isReady()||t.getWaitingItemsCount()>0;){await new Promise(c=>setTimeout(c,150));let s=l-t.getWaitingItemsCount();n?.onProgress?.(.5+s/l*.5)}n?.onProgress?.(1),xe(t),Ae(t),t.metadata?.rendering&&(et(t,t.metadata.rendering),t.activeCamera&&tt(t.activeCamera,e)),t.metadata?.physicsGravity&&t.getPhysicsEngine()?.setGravity(ot.Vector3.FromArray(t.metadata?.physicsGravity)),R(t,t,r,e),t.transformNodes.forEach(s=>{R(t,s,r,e)}),t.meshes.forEach(s=>{_e(s),R(t,s,r,e)}),t.lights.forEach(s=>{R(t,s,r,e)}),t.cameras.forEach(s=>{R(t,s,r,e)})}i(kt,"loadScene");var at=require("babylonjs");async function zt(e,o,t){let n=await(await fetch(e+o)).json(),s=at.Tools.Instantiate(n.customType).Parse(n,t,e);return s.id=n.id,s.uniqueId=n.uniqueId,s}i(zt,"loadMaterialFromFile");function jt(e){e.setTextureFormatToUse(["-dxt.ktx","-astc.ktx","-pvrtc.ktx","-etc1.ktx","-etc2.ktx"])}i(jt,"configureEngineToUseCompressedTextures");var A=require("babylonjs");function k(e){if(!isNaN(parseFloat(e))&&isFinite(e))return A.Animation.ANIMATIONTYPE_FLOAT;switch(e?.getClassName?.()){case"Vector2":return A.Animation.ANIMATIONTYPE_VECTOR2;case"Vector3":return A.Animation.ANIMATIONTYPE_VECTOR3;case"Quaternion":return A.Animation.ANIMATIONTYPE_QUATERNION;case"Color3":return A.Animation.ANIMATIONTYPE_COLOR3;case"Color4":return A.Animation.ANIMATIONTYPE_COLOR4;case"Size":return A.Animation.ANIMATIONTYPE_SIZE;case"Matrix":return A.Animation.ANIMATIONTYPE_MATRIX}return null}i(k,"getAnimationTypeForObject");function Ht(e){return function(o,t){let r=o.constructor;r._NodesFromScene??=[],r._NodesFromScene.push({propertyKey:t,nodeName:e})}}i(Ht,"nodeFromScene");function Yt(e,o=!1){return function(t,r){let n=t.constructor;n._NodesFromDescendants??=[],n._NodesFromDescendants.push({propertyKey:r,nodeName:e,directDescendantsOnly:o})}}i(Yt,"nodeFromDescendants");function Wt(e){return function(o,t){let r=o.constructor;r._AnimationGroups??=[],r._AnimationGroups.push({animationGroupName:e,propertyKey:t})}}i(Wt,"animationGroupFromScene");function Ut(e,o){return function(t,r){let n=t.constructor;n._GuiFromAsset??=[],n._GuiFromAsset.push({propertyKey:r,pathInAssets:e,onGuiCreated:o})}}i(Ut,"guiFromAsset");function $t(e){return function(o,t){let r=o.constructor;r._SoundsFromScene??=[],r._SoundsFromScene.push({propertyKey:t,soundName:e})}}i($t,"soundFromScene");function Qt(e){return function(o,t){let r=o.constructor;r._ParticleSystemsFromScene??=[],r._ParticleSystemsFromScene.push({propertyKey:t,particleSystemName:e})}}i(Qt,"particleSystemFromScene");function Zt(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"boolean"}})}}i(Zt,"visibleAsBoolean");function qt(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"number"}})}}i(qt,"visibleAsNumber");function Xt(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"vector2"}})}}i(Xt,"visibleAsVector2");function Jt(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"vector3"}})}}i(Jt,"visibleAsVector3");function er(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"color3"}})}}i(er,"visibleAsColor3");function tr(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"color4"}})}}i(tr,"visibleAsColor4");function rr(e,o,t){return function(r,n){let l=r.constructor;l._VisibleInInspector??=[],l._VisibleInInspector.push({label:o,propertyKey:n,configuration:{...t,entityType:e,type:"entity"}})}}i(rr,"visibleAsEntity");function nr(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"texture"}})}}i(nr,"visibleAsTexture");function or(e,o){return function(t,r){let n=t.constructor;n._VisibleInInspector??=[],n._VisibleInInspector.push({label:e,propertyKey:r,configuration:{...o,type:"keymap"}})}}i(or,"visibleAsKeyMap");var q=require("babylonjs");function lt(e,o){let t;switch(e){case q.Animation.ANIMATIONTYPE_FLOAT:t=o.value;break;default:t=o.value.clone();break}return{value:t,frame:o.frame,interpolation:o.interpolation,inTangent:e===q.Animation.ANIMATIONTYPE_FLOAT?o.inTangent:o.inTangent?.clone(),outTangent:e===q.Animation.ANIMATIONTYPE_FLOAT?o.outTangent:o.outTangent?.clone()}}i(lt,"cloneKey");function X(e,o){let t=o.split("."),r=e;for(let n=0;n<t.length;++n)r=r[t[n]];return r}i(X,"getPropertyValue");var v=require("babylonjs"),J=require("babylonjs"),I=require("babylonjs");function ir(e,o){return{name:e.name,framesPerSecond:e.framesPerSecond,outputFramesPerSecond:e.outputFramesPerSecond,tracks:e.tracks.map(t=>{let r=null,n=null;if(t.node?(r=o.getNodeById(t.node),r||(r=o.particleSystems?.find(s=>s.id===t.node)??null)):t.defaultRenderingPipeline&&(r=K()),t.propertyPath){let s=X(r,t.propertyPath);n=k(s)}let l=null;return t.sound&&(l=W(t.sound,o)),{node:r,sound:l,propertyPath:t.propertyPath,defaultRenderingPipeline:t.defaultRenderingPipeline,animationGroup:t.animationGroup?o.getAnimationGroupByName(t.animationGroup):null,animationGroups:t.animationGroups,sounds:t.sounds,keyFrameEvents:t.keyFrameEvents?.map(s=>{let c={...s};switch(s.data?.type){case"set-enabled":c.data={type:"set-enabled",value:s.data.value,node:o.getNodeById(s.data.node)};break;case"apply-impulse":c.data={type:"apply-impulse",radius:s.data.radius,mesh:o.getMeshById(s.data.mesh),force:I.Vector3.FromArray(s.data.force),contactPoint:I.Vector3.FromArray(s.data.contactPoint)};break}return c}),keyFrameAnimations:r&&n!==null&&t.keyFrameAnimations?.map(s=>{let c=s.type==="key"?s:null;if(c)return{...c,value:C(c.value,n),inTangent:C(c.inTangent,n),outTangent:C(c.outTangent,n)};let u=s.type==="cut"?s:null;if(u)return{...u,key1:{...u.key1,value:C(u.key1.value,n),inTangent:C(u.key1.inTangent,n),outTangent:C(u.key1.outTangent,n)},key2:{...u.key2,value:C(u.key2.value,n),inTangent:C(u.key2.inTangent,n),outTangent:C(u.key2.outTangent,n)}};throw new Error(`Unknown key frame type: ${s.type}`)})}})}}i(ir,"parseCinematic");function C(e,o){if(e===null)return null;if(e!==void 0)switch(o){case v.Animation.ANIMATIONTYPE_FLOAT:return e;case v.Animation.ANIMATIONTYPE_VECTOR2:return I.Vector2.FromArray(e);case v.Animation.ANIMATIONTYPE_VECTOR3:return I.Vector3.FromArray(e);case v.Animation.ANIMATIONTYPE_QUATERNION:return I.Quaternion.FromArray(e);case v.Animation.ANIMATIONTYPE_COLOR3:return J.Color3.FromArray(e);case v.Animation.ANIMATIONTYPE_COLOR4:return J.Color4.FromArray(e);case v.Animation.ANIMATIONTYPE_MATRIX:return I.Matrix.FromArray(e)}}i(C,"parseCinematicKeyValue");function ct(e){e.node?.setEnabled(e.value)}i(ct,"handleSetEnabledEvent");var De=require("babylonjs"),mt=De.Vector3.Zero();function ut(e,o){let t=o.mesh?[o.mesh]:e.meshes.filter(r=>r.physicsAggregate);o.radius&&(t=t.filter(r=>{let n=r.getBoundingInfo().boundingBox.centerWorld;return De.Vector3.Distance(n,o.contactPoint)<=o.radius})),t.forEach(r=>{if(r.physicsAggregate?.body){let n=o.contactPoint.subtract(r.getBoundingInfo().boundingBox.centerWorld);n.multiplyInPlace(o.force),r.physicsAggregate.body.setLinearVelocity(mt),r.physicsAggregate.body.setAngularVelocity(mt),r.physicsAggregate.body.applyImpulse(n.negateInPlace(),o.contactPoint)}})}i(ut,"handleApplyImpulseEvent");var pt=require("babylonjs"),T=require("babylonjs"),z=require("babylonjs"),gt=require("babylonjs");function sr(e,o,t){let r=new gt.AnimationGroup(e.name,o);return e.tracks.forEach(n=>{let l=n.animationGroup;l&&n.animationGroups?.forEach(h=>{l.targetedAnimations.forEach(f=>{let p=null;e:{let x=r.targetedAnimations.filter(j=>j.target===f.target);if(x.length){let j=x.find(ft=>ft.animation.targetProperty===f.animation.targetProperty);if(j){p=j.animation;break e}}p=f.animation.clone(),p.setKeys([]),p.name=pt.Tools.RandomId(),p.framePerSecond=e.framesPerSecond}let g=p.getKeys(),M=f.animation.getKeys(),ee=h.speed,ve=e.framesPerSecond/f.animation.framePerSecond/ee;M.forEach(x=>{x.frame>=h.startFrame&&x.frame<=h.endFrame&&g.push({...lt(f.animation.dataType,x),frame:h.frame+x.frame*ve})}),p.setKeys(g),r.addTargetedAnimation(p,f.target)})});let s=n.sound,c=s?.getAudioBuffer();if(!t?.ignoreSounds&&s&&c&&n.sounds?.length){let h={dummy:0},f=new T.Animation(s.name,"dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),p=0;n.sounds?.forEach(g=>{let M=g.endFrame-g.startFrame;p=Math.max(p,g.frame+M),f.addEvent(new z.AnimationEvent(g.frame,ee=>{let x=(ee-g.frame+g.startFrame)/e.framesPerSecond;s.play(0,x)},!1)),f.addEvent(new z.AnimationEvent(g.frame+M,()=>{s.stop()}))}),f.setKeys([{frame:0,value:0},{frame:p,value:p}]),r.addTargetedAnimation(f,h)}if(n.keyFrameEvents){let h={dummy:0},f=new T.Animation("events","dummy",60,T.Animation.ANIMATIONTYPE_FLOAT,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),p=0;n.keyFrameEvents?.forEach(g=>{p=Math.max(p,g.frame),f.addEvent(new z.AnimationEvent(g.frame,()=>{switch(g.data?.type){case"set-enabled":ct(g.data);break;case"apply-impulse":ut(o,g.data);break}}))}),f.setKeys([{frame:0,value:0},{frame:p,value:p}]),r.addTargetedAnimation(f,h)}let u=n.defaultRenderingPipeline?K():n.node;if(!u||!n.propertyPath||!n.keyFrameAnimations)return;let y=X(u,n.propertyPath),b=k(y);if(b===null)return;let O=new T.Animation(n.propertyPath,n.propertyPath,60,b,T.Animation.ANIMATIONLOOPMODE_CYCLE,!1),F=[];n.keyFrameAnimations?.forEach(h=>{let f=h.type==="key"?h:null;if(f)return F.push(f);let p=h.type==="cut"?h:null;p&&(F.push(p.key1),F.push(p.key2),Y(u)&&n.propertyPath==="position"&&O.addEvent(new z.AnimationEvent(p.key1.frame,()=>{let g=de();if(!g)return;let M=g.motionStrength;g.motionStrength=0,requestAnimationFrame(()=>{g.motionStrength=M})})))}),O.setKeys(F),r.addTargetedAnimation(O,u)}),r.normalize(),r}i(sr,"generateCinematicAnimationGroup");function ar(e){return e.type==="key"}i(ar,"isCinematicKey");function lr(e){return e.type==="cut"}i(lr,"isCinematicKeyCut");function cr(e){return e.type==="event"}i(cr,"isCinematicKeyEvent");function mr(e){return e.type==="group"}i(mr,"isCinematicGroup");function ur(e){return e.type==="sound"}i(ur,"isCinematicSound");0&&(module.exports={_applyScriptsForObject,animationGroupFromScene,configureEngineToUseCompressedTextures,configureShadowMapRefreshRate,configureShadowMapRenderListPredicate,createDefaultRenderingPipeline,createMotionBlurPostProcess,createSSAO2RenderingPipeline,createSSRRenderingPipeline,createVLSPostProcess,defaultPipelineCameraConfigurations,disposeDefaultRenderingPipeline,disposeMotionBlurPostProcess,disposeSSAO2RenderingPipeline,disposeSSRRenderingPipeline,disposeVLSPostProcess,generateCinematicAnimationGroup,getAllScriptsByClassForObject,getAnimationTypeForObject,getDefaultRenderingPipeline,getMotionBlurPostProcess,getPowerOfTwoUntil,getSSAO2RenderingPipeline,getSSRRenderingPipeline,getScriptByClassForObject,getVLSPostProcess,guiFromAsset,isAbstractMesh,isAnyParticleSystem,isArcRotateCamera,isBone,isCamera,isCinematicGroup,isCinematicKey,isCinematicKeyCut,isCinematicKeyEvent,isCinematicSound,isDirectionalLight,isFreeCamera,isGPUParticleSystem,isGroundMesh,isHemisphericLight,isInstancedMesh,isLight,isMesh,isNode,isParticleSystem,isPointLight,isScene,isSpotLight,isTexture,isTransformNode,loadMaterialFromFile,loadScene,motionBlurPostProcessCameraConfigurations,nodeFromDescendants,nodeFromScene,parseCinematic,parseCinematicKeyValue,parseDefaultRenderingPipeline,parseMotionBlurPostProcess,parseSSAO2RenderingPipeline,parseSSRRenderingPipeline,parseVLSPostProcess,particleSystemFromScene,registerScriptInstance,serializeDefaultRenderingPipeline,serializeMotionBlurPostProcess,serializeSSAO2RenderingPipeline,serializeSSRRenderingPipeline,serializeVLSPostProcess,setDefaultRenderingPipelineRef,setMotionBlurPostProcessRef,setSSAO2RenderingPipelineRef,setSSRRenderingPipelineRef,setVLSPostProcessRef,soundFromScene,ssaoRenderingPipelineCameraConfigurations,ssrRenderingPipelineCameraConfigurations,visibleAsBoolean,visibleAsColor3,visibleAsColor4,visibleAsEntity,visibleAsKeyMap,visibleAsNumber,visibleAsTexture,visibleAsVector2,visibleAsVector3,vlsPostProcessCameraConfigurations});
@@ -1,4 +1,5 @@
1
1
  import { Color3, Color4 } from "@babylonjs/core/Maths/math.color";
2
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture";
2
3
  import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
3
4
  import { AdvancedDynamicTexture } from "@babylonjs/gui/2D/advancedDynamicTexture";
4
5
  import { getSoundById } from "../tools/sound";
@@ -58,6 +59,7 @@ export function applyDecorators(scene, object, script, instance, rootUrl) {
58
59
  switch (params.configuration.type) {
59
60
  case "number":
60
61
  case "boolean":
62
+ case "keymap":
61
63
  instance[propertyKey] = value;
62
64
  break;
63
65
  case "vector2":
@@ -89,6 +91,11 @@ export function applyDecorators(scene, object, script, instance, rootUrl) {
89
91
  break;
90
92
  }
91
93
  break;
94
+ case "texture":
95
+ if (value) {
96
+ instance[propertyKey] = Texture.Parse(value, scene, rootUrl);
97
+ }
98
+ break;
92
99
  }
93
100
  }
94
101
  });
@@ -154,4 +154,48 @@ export function visibleAsEntity(entityType, label, configuration) {
154
154
  });
155
155
  };
156
156
  }
157
+ /**
158
+ * Makes the decorated property visible in the editor inspector as a Texture.
159
+ * The property can be customized per object in the editor and the custom value is applied
160
+ * once the script is invoked at runtime in the game/application.
161
+ * This can be used only by scripts using Classes.
162
+ * @param label defines the optional label displayed in the inspector in the editor.
163
+ * @param configuration defines the optional configuration for the field in the inspector (accept cubes, etc.).
164
+ */
165
+ export function visibleAsTexture(label, configuration) {
166
+ return function (target, propertyKey) {
167
+ const ctor = target.constructor;
168
+ ctor._VisibleInInspector ??= [];
169
+ ctor._VisibleInInspector.push({
170
+ label,
171
+ propertyKey,
172
+ configuration: {
173
+ ...configuration,
174
+ type: "texture",
175
+ },
176
+ });
177
+ };
178
+ }
179
+ /**
180
+ * Makes the decorated property visible in the editor inspector as a KeyMap.
181
+ * The property can be customized per object in the editor and the custom value is applied
182
+ * once the script is invoked at runtime in the game/application.
183
+ * This can be used only by scripts using Classes.
184
+ * @param label defines the optional label displayed in the inspector in the editor.
185
+ * @param configuration defines the optional configuration for the field in the inspector (description, etc.).
186
+ */
187
+ export function visibleAsKeyMap(label, configuration) {
188
+ return function (target, propertyKey) {
189
+ const ctor = target.constructor;
190
+ ctor._VisibleInInspector ??= [];
191
+ ctor._VisibleInInspector.push({
192
+ label,
193
+ propertyKey,
194
+ configuration: {
195
+ ...configuration,
196
+ type: "keymap",
197
+ },
198
+ });
199
+ };
200
+ }
157
201
  //# sourceMappingURL=inspector.js.map
@@ -1,4 +1,6 @@
1
1
  export * from "./loading/loader";
2
+ export * from "./loading/material";
3
+ export * from "./loading/script";
2
4
  export * from "./tools/guards";
3
5
  export * from "./tools/texture";
4
6
  export * from "./tools/light";
@@ -2,7 +2,7 @@ import { Vector3 } from "@babylonjs/core/Maths/math.vector";
2
2
  import { AppendSceneAsync } from "@babylonjs/core/Loading/sceneLoader";
3
3
  import { SceneLoaderFlags } from "@babylonjs/core/Loading/sceneLoaderFlags";
4
4
  import { isMesh } from "../tools/guards";
5
- import { applyScriptForObject } from "./script";
5
+ import { _applyScriptsForObject } from "./script";
6
6
  import { configurePhysicsAggregate } from "./physics";
7
7
  import { applyRenderingConfigurations } from "./rendering";
8
8
  import { applyRenderingConfigurationForCamera } from "../rendering/tools";
@@ -41,19 +41,19 @@ export async function loadScene(rootUrl, sceneFilename, scene, scriptsMap, optio
41
41
  if (scene.metadata?.physicsGravity) {
42
42
  scene.getPhysicsEngine()?.setGravity(Vector3.FromArray(scene.metadata?.physicsGravity));
43
43
  }
44
- applyScriptForObject(scene, scene, scriptsMap, rootUrl);
44
+ _applyScriptsForObject(scene, scene, scriptsMap, rootUrl);
45
45
  scene.transformNodes.forEach((transformNode) => {
46
- applyScriptForObject(scene, transformNode, scriptsMap, rootUrl);
46
+ _applyScriptsForObject(scene, transformNode, scriptsMap, rootUrl);
47
47
  });
48
48
  scene.meshes.forEach((mesh) => {
49
49
  configurePhysicsAggregate(mesh);
50
- applyScriptForObject(scene, mesh, scriptsMap, rootUrl);
50
+ _applyScriptsForObject(scene, mesh, scriptsMap, rootUrl);
51
51
  });
52
52
  scene.lights.forEach((light) => {
53
- applyScriptForObject(scene, light, scriptsMap, rootUrl);
53
+ _applyScriptsForObject(scene, light, scriptsMap, rootUrl);
54
54
  });
55
55
  scene.cameras.forEach((camera) => {
56
- applyScriptForObject(scene, camera, scriptsMap, rootUrl);
56
+ _applyScriptsForObject(scene, camera, scriptsMap, rootUrl);
57
57
  });
58
58
  }
59
59
  //# sourceMappingURL=loader.js.map
@@ -0,0 +1,19 @@
1
+ import { Tools } from "@babylonjs/core/Misc/tools";
2
+ /**
3
+ * Loads the file located at `rootUrl + relativePath` and creates a new material from it.
4
+ * @param rootUrl defines the absolute root url for the assets. (generally "/scene/")
5
+ * @param relativePath defines the path relative to `rootUrl` for the material file
6
+ * @param scene defines the reference to the scene where to add the loaded material.
7
+ * @returns the reference to the created material.
8
+ * @example await loadMaterialFromFile<PBRMaterial>("/scene/", "assets/floor.material", scene);
9
+ */
10
+ export async function loadMaterialFromFile(rootUrl, relativePath, scene) {
11
+ const response = await fetch(rootUrl + relativePath);
12
+ const data = await response.json();
13
+ const ctor = Tools.Instantiate(data.customType);
14
+ const material = ctor.Parse(data, scene, rootUrl);
15
+ material.id = data.id;
16
+ material.uniqueId = data.uniqueId;
17
+ return material;
18
+ }
19
+ //# sourceMappingURL=material.js.map
@@ -1,5 +1,9 @@
1
1
  import { applyDecorators } from "../decorators/apply";
2
- export function applyScriptForObject(scene, object, scriptsMap, rootUrl) {
2
+ import { isAnyParticleSystem, isNode, isScene } from "../tools/guards";
3
+ /**
4
+ * @internal
5
+ */
6
+ export function _applyScriptsForObject(scene, object, scriptsMap, rootUrl) {
3
7
  if (!object.metadata) {
4
8
  return;
5
9
  }
@@ -13,6 +17,7 @@ export function applyScriptForObject(scene, object, scriptsMap, rootUrl) {
13
17
  }
14
18
  if (exports.default) {
15
19
  const instance = new exports.default(object);
20
+ registerScriptInstance(object, instance, script.key);
16
21
  applyDecorators(scene, object, script, instance, rootUrl);
17
22
  if (instance.onStart) {
18
23
  scene.onBeforeRenderObservable.addOnce(() => instance.onStart());
@@ -32,4 +37,82 @@ export function applyScriptForObject(scene, object, scriptsMap, rootUrl) {
32
37
  });
33
38
  object.metadata.scripts = undefined;
34
39
  }
40
+ const scriptsDictionary = new Map();
41
+ /**
42
+ * When a scene is being loaded, scripts that were attached to objects in the scene using the Editor are processed.
43
+ * This function registers the instance of scripts per object in order to retrieve them later.
44
+ * @param object defines the object in the scene on which the script is attached to.
45
+ * @param scriptInstance defines the instance of the script to register.
46
+ * @param key defines the key of the script. This value is used to identify the script.
47
+ */
48
+ export function registerScriptInstance(object, scriptInstance, key) {
49
+ const registeredScript = {
50
+ key,
51
+ instance: scriptInstance,
52
+ };
53
+ if (!scriptsDictionary.has(object)) {
54
+ scriptsDictionary.set(object, [registeredScript]);
55
+ }
56
+ else {
57
+ scriptsDictionary.get(object).push(registeredScript);
58
+ }
59
+ if (isNode(object) || isAnyParticleSystem(object) || isScene(object)) {
60
+ object.onDisposeObservable.addOnce((() => {
61
+ scriptsDictionary.delete(object);
62
+ }));
63
+ }
64
+ }
65
+ /**
66
+ * Returns all the instances of the script attached to the given object that matches the given class type.
67
+ * The same script can be attached multiple times to the same object. If you ensure that ONLY DISTINCT scripts
68
+ * are attached to the object, you can use `getScriptByClassForObject` which will return the unique instance for the given object.
69
+ * @param object defines the reference to the object where the script to retrieve is attached to.
70
+ * @param classType defines the class of the type to retrieve
71
+ * @example
72
+ * import { IScript, getAllScriptsByClassForObject } from "babylonjs-editor-tools";
73
+ *
74
+ * class ScriptClass implements IScript {
75
+ * public onStart(): void {
76
+ * const instances = getAllScriptsByClassForObject(mesh, OtherScriptClass);
77
+ * instances.forEach((i) => {
78
+ * i.doSomething();
79
+ * });
80
+ * }
81
+ * }
82
+ *
83
+ * class OtherScriptClass implements IScript {
84
+ * public doSomething(): void {
85
+ * console.log("Doing something!");
86
+ * }
87
+ * }
88
+ */
89
+ export function getAllScriptsByClassForObject(object, classType) {
90
+ const data = scriptsDictionary.get(object);
91
+ const result = data?.filter((s) => s.instance.constructor === classType);
92
+ return result?.map((r) => r.instance) ?? null;
93
+ }
94
+ /**
95
+ * Returns the instance of the script attached to the given object that matches the given class type.
96
+ * @param object defines the reference to the object where the script to retrieve is attached to.
97
+ * @param classType defines the class of the type to retrieve
98
+ * @example
99
+ * import { IScript, getScriptByClassForObject } from "babylonjs-editor-tools";
100
+ *
101
+ * class ScriptClass implements IScript {
102
+ * public onStart(): void {
103
+ * const instance = getScriptByClassForObject(mesh, OtherScriptClass);
104
+ * instance.doSomething();
105
+ * }
106
+ * }
107
+ *
108
+ * class OtherScriptClass implements IScript {
109
+ * public doSomething(): void {
110
+ * console.log("Doing something!");
111
+ * }
112
+ * }
113
+ */
114
+ export function getScriptByClassForObject(object, classType) {
115
+ const result = getAllScriptsByClassForObject(object, classType);
116
+ return result?.[0] ?? null;
117
+ }
35
118
  //# sourceMappingURL=script.js.map
@@ -122,4 +122,59 @@ export function isSpotLight(object) {
122
122
  export function isHemisphericLight(object) {
123
123
  return object.getClassName?.() === "HemisphericLight";
124
124
  }
125
+ /**
126
+ * Returns wether or not the given object is a Light.
127
+ * @param object defines the reference to the object to test its class name.
128
+ */
129
+ export function isLight(object) {
130
+ switch (object.getClassName?.()) {
131
+ case "Light":
132
+ case "PointLight":
133
+ case "SpotLight":
134
+ case "DirectionalLight":
135
+ case "HemisphericLight":
136
+ return true;
137
+ }
138
+ return false;
139
+ }
140
+ /**
141
+ * Returns wether or not the given object is a Node.
142
+ * @param object defines the reference to the object to test its class name.
143
+ */
144
+ export function isNode(object) {
145
+ return isAbstractMesh(object) || isTransformNode(object) || isLight(object) || isCamera(object);
146
+ }
147
+ /**
148
+ * Returns wether or not the given object is a Scene.
149
+ * @param object defines the reference to the object to test its class name.
150
+ */
151
+ export function isScene(object) {
152
+ return object.getClassName?.() === "Scene";
153
+ }
154
+ /**
155
+ * Returns wether or not the given object is a ParticleSystem.
156
+ * @param object defines the reference to the object to test its class name.
157
+ */
158
+ export function isParticleSystem(object) {
159
+ return object.getClassName?.() === "ParticleSystem";
160
+ }
161
+ /**
162
+ * Returns wether or not the given object is a GPUParticleSystem.
163
+ * @param object defines the reference to the object to test its class name.
164
+ */
165
+ export function isGPUParticleSystem(object) {
166
+ return object.getClassName?.() === "GPUParticleSystem";
167
+ }
168
+ /**
169
+ * Returns wether or not the given object is a IParticleSystem.
170
+ * @param object defines the reference to the object to test its class name.
171
+ */
172
+ export function isAnyParticleSystem(object) {
173
+ switch (object.getClassName?.()) {
174
+ case "ParticleSystem":
175
+ case "GPUParticleSystem":
176
+ return true;
177
+ }
178
+ return false;
179
+ }
125
180
  //# sourceMappingURL=guards.js.map
@@ -1,4 +1,4 @@
1
- export type VisibleInInspectorDecoratorType = "number" | "boolean" | "vector2" | "vector3" | "color3" | "color4" | "entity";
1
+ export type VisibleInInspectorDecoratorType = "number" | "boolean" | "vector2" | "vector3" | "color3" | "color4" | "entity" | "texture" | "keymap";
2
2
  export type VisibleInInspectorDecoratorConfiguration = {
3
3
  type: VisibleInInspectorDecoratorType;
4
4
  description?: string;
@@ -11,7 +11,7 @@ export type VisibleInInspectorDecoratorConfiguration = {
11
11
  * @param label defines the optional label displayed in the inspector in the editor.
12
12
  * @param configuration defines the optional configuration for the field in the inspector (description, etc.).
13
13
  */
14
- export declare function visibleAsBoolean(label?: string, configuration?: Omit<VisibleInInspectorDecoratorNumberConfiguration, "type">): (target: any, propertyKey: string | Symbol) => void;
14
+ export declare function visibleAsBoolean(label?: string, configuration?: Omit<VisibleInInspectorDecoratorConfiguration, "type">): (target: any, propertyKey: string | Symbol) => void;
15
15
  /**
16
16
  * Makes the decorated property visible in the editor inspector as a number.
17
17
  * The property can be customized per object in the editor and the custom value is applied
@@ -91,8 +91,30 @@ export type VisibleInInspectorDecoratorColor4Configuration = VisibleInInspectorD
91
91
  * @param label defines the optional label displayed in the inspector in the editor.
92
92
  * @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
93
93
  */
94
- export declare function visibleAsEntity(entityType: VisibleAsEntityType, label?: string, configuration?: Omit<VisibleInInspectorDecoratorEntityConfiguration, "type">): (target: any, propertyKey: string | Symbol) => void;
94
+ export declare function visibleAsEntity(entityType: VisibleAsEntityType, label?: string, configuration?: Omit<VisibleInInspectorDecoratorEntityConfiguration, "type" | "entityType">): (target: any, propertyKey: string | Symbol) => void;
95
95
  export type VisibleAsEntityType = "node" | "sound" | "animationGroup" | "particleSystem";
96
96
  export type VisibleInInspectorDecoratorEntityConfiguration = VisibleInInspectorDecoratorConfiguration & {
97
97
  entityType?: VisibleAsEntityType;
98
98
  };
99
+ /**
100
+ * Makes the decorated property visible in the editor inspector as a Texture.
101
+ * The property can be customized per object in the editor and the custom value is applied
102
+ * once the script is invoked at runtime in the game/application.
103
+ * This can be used only by scripts using Classes.
104
+ * @param label defines the optional label displayed in the inspector in the editor.
105
+ * @param configuration defines the optional configuration for the field in the inspector (accept cubes, etc.).
106
+ */
107
+ export declare function visibleAsTexture(label?: string, configuration?: Omit<VisibleInInspectorDecoratorTextureConfiguration, "type">): (target: any, propertyKey: string | Symbol) => void;
108
+ export type VisibleInInspectorDecoratorTextureConfiguration = VisibleInInspectorDecoratorConfiguration & {
109
+ acceptCubes?: boolean;
110
+ onlyCubes?: boolean;
111
+ };
112
+ /**
113
+ * Makes the decorated property visible in the editor inspector as a KeyMap.
114
+ * The property can be customized per object in the editor and the custom value is applied
115
+ * once the script is invoked at runtime in the game/application.
116
+ * This can be used only by scripts using Classes.
117
+ * @param label defines the optional label displayed in the inspector in the editor.
118
+ * @param configuration defines the optional configuration for the field in the inspector (description, etc.).
119
+ */
120
+ export declare function visibleAsKeyMap(label?: string, configuration?: Omit<VisibleInInspectorDecoratorConfiguration, "type">): (target: any, propertyKey: string | Symbol) => void;
@@ -1,4 +1,6 @@
1
1
  export * from "./loading/loader";
2
+ export * from "./loading/material";
3
+ export * from "./loading/script";
2
4
  export * from "./tools/guards";
3
5
  export * from "./tools/texture";
4
6
  export * from "./tools/light";
@@ -18,13 +18,23 @@ export type ScriptMap = Record<string, {
18
18
  /**
19
19
  * Defines the overall desired quality of the scene.
20
20
  * In other words, defines the quality of textures that will be loaded in terms of dimensions.
21
- * The editor computes automatic "hight (untouched)", "medium (half)", and "low (quarter)" quality levels for textures.
21
+ * The editor computes automatic "high (untouched)", "medium (half)", and "low (quarter)" quality levels for textures.
22
22
  * Using "medium" or "low" quality levels will reduce the memory usage and improve the performance of the scene
23
23
  * especially on mobiles where memory is limited.
24
24
  */
25
25
  export type SceneLoaderQualitySelector = "low" | "medium" | "high";
26
26
  export type SceneLoaderOptions = {
27
+ /**
28
+ * Defines the quality of the scene.
29
+ * This will affect the quality of textures that will be loaded in terms of dimensions.
30
+ * The editor computes automatic "high (untouched)", "medium (half)", and "low (quarter)" quality levels for textures.
31
+ * Using "medium" or "low" quality levels will reduce the memory usage and improve the performance of the scene
32
+ * especially on mobiles where memory is limited.
33
+ */
27
34
  quality?: SceneLoaderQualitySelector;
35
+ /**
36
+ * Defines the function called to notify the loading progress in interval [0, 1]
37
+ */
28
38
  onProgress?: (value: number) => void;
29
39
  };
30
40
  declare module "@babylonjs/core/scene" {
@@ -0,0 +1,11 @@
1
+ import { Scene } from "@babylonjs/core/scene";
2
+ import { Material } from "@babylonjs/core/Materials/material";
3
+ /**
4
+ * Loads the file located at `rootUrl + relativePath` and creates a new material from it.
5
+ * @param rootUrl defines the absolute root url for the assets. (generally "/scene/")
6
+ * @param relativePath defines the path relative to `rootUrl` for the material file
7
+ * @param scene defines the reference to the scene where to add the loaded material.
8
+ * @returns the reference to the created material.
9
+ * @example await loadMaterialFromFile<PBRMaterial>("/scene/", "assets/floor.material", scene);
10
+ */
11
+ export declare function loadMaterialFromFile<T extends Material>(rootUrl: string, relativePath: string, scene: Scene): Promise<T>;
@@ -1,3 +1,71 @@
1
1
  import { Scene } from "@babylonjs/core/scene";
2
+ import { IScript } from "../script";
2
3
  import { ScriptMap } from "./loader";
3
- export declare function applyScriptForObject(scene: Scene, object: any, scriptsMap: ScriptMap, rootUrl: string): void;
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare function _applyScriptsForObject(scene: Scene, object: any, scriptsMap: ScriptMap, rootUrl: string): void;
8
+ export interface IRegisteredScript {
9
+ /**
10
+ * Defines the key of the script. Refer to scriptMap.
11
+ */
12
+ key: string;
13
+ /**
14
+ * Defines the instance of the script that was created while loading the scene.
15
+ */
16
+ instance: IScript;
17
+ }
18
+ /**
19
+ * When a scene is being loaded, scripts that were attached to objects in the scene using the Editor are processed.
20
+ * This function registers the instance of scripts per object in order to retrieve them later.
21
+ * @param object defines the object in the scene on which the script is attached to.
22
+ * @param scriptInstance defines the instance of the script to register.
23
+ * @param key defines the key of the script. This value is used to identify the script.
24
+ */
25
+ export declare function registerScriptInstance(object: any, scriptInstance: IScript, key: string): void;
26
+ /**
27
+ * Returns all the instances of the script attached to the given object that matches the given class type.
28
+ * The same script can be attached multiple times to the same object. If you ensure that ONLY DISTINCT scripts
29
+ * are attached to the object, you can use `getScriptByClassForObject` which will return the unique instance for the given object.
30
+ * @param object defines the reference to the object where the script to retrieve is attached to.
31
+ * @param classType defines the class of the type to retrieve
32
+ * @example
33
+ * import { IScript, getAllScriptsByClassForObject } from "babylonjs-editor-tools";
34
+ *
35
+ * class ScriptClass implements IScript {
36
+ * public onStart(): void {
37
+ * const instances = getAllScriptsByClassForObject(mesh, OtherScriptClass);
38
+ * instances.forEach((i) => {
39
+ * i.doSomething();
40
+ * });
41
+ * }
42
+ * }
43
+ *
44
+ * class OtherScriptClass implements IScript {
45
+ * public doSomething(): void {
46
+ * console.log("Doing something!");
47
+ * }
48
+ * }
49
+ */
50
+ export declare function getAllScriptsByClassForObject<T>(object: any, classType: T): T[];
51
+ /**
52
+ * Returns the instance of the script attached to the given object that matches the given class type.
53
+ * @param object defines the reference to the object where the script to retrieve is attached to.
54
+ * @param classType defines the class of the type to retrieve
55
+ * @example
56
+ * import { IScript, getScriptByClassForObject } from "babylonjs-editor-tools";
57
+ *
58
+ * class ScriptClass implements IScript {
59
+ * public onStart(): void {
60
+ * const instance = getScriptByClassForObject(mesh, OtherScriptClass);
61
+ * instance.doSomething();
62
+ * }
63
+ * }
64
+ *
65
+ * class OtherScriptClass implements IScript {
66
+ * public doSomething(): void {
67
+ * console.log("Doing something!");
68
+ * }
69
+ * }
70
+ */
71
+ export declare function getScriptByClassForObject<T>(object: any, classType: T): NonNullable<T> | null;
@@ -1,3 +1,5 @@
1
+ import { Scene } from "@babylonjs/core/scene";
2
+ import { Node } from "@babylonjs/core/node";
1
3
  import { Bone } from "@babylonjs/core/Bones/bone";
2
4
  import { Mesh } from "@babylonjs/core/Meshes/mesh";
3
5
  import { GroundMesh } from "@babylonjs/core/Meshes/groundMesh";
@@ -7,10 +9,14 @@ import { Texture } from "@babylonjs/core/Materials/Textures/texture";
7
9
  import { Camera } from "@babylonjs/core/Cameras/camera";
8
10
  import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
9
11
  import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera";
12
+ import { Light } from "@babylonjs/core/Lights/light";
10
13
  import { SpotLight } from "@babylonjs/core/Lights/spotLight";
11
14
  import { PointLight } from "@babylonjs/core/Lights/pointLight";
12
15
  import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
13
16
  import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight";
17
+ import { ParticleSystem } from "@babylonjs/core/Particles/particleSystem";
18
+ import { IParticleSystem } from "@babylonjs/core/Particles/IParticleSystem";
19
+ import { GPUParticleSystem } from "@babylonjs/core/Particles/gpuParticleSystem";
14
20
  /**
15
21
  * Returns wether or not the given object is an AbstractMesh.
16
22
  * @param object defines the reference to the object to test its class name.
@@ -81,3 +87,33 @@ export declare function isSpotLight(object: any): object is SpotLight;
81
87
  * @param object defines the reference to the object to test its class name.
82
88
  */
83
89
  export declare function isHemisphericLight(object: any): object is HemisphericLight;
90
+ /**
91
+ * Returns wether or not the given object is a Light.
92
+ * @param object defines the reference to the object to test its class name.
93
+ */
94
+ export declare function isLight(object: any): object is Light;
95
+ /**
96
+ * Returns wether or not the given object is a Node.
97
+ * @param object defines the reference to the object to test its class name.
98
+ */
99
+ export declare function isNode(object: any): object is Node;
100
+ /**
101
+ * Returns wether or not the given object is a Scene.
102
+ * @param object defines the reference to the object to test its class name.
103
+ */
104
+ export declare function isScene(object: any): object is Scene;
105
+ /**
106
+ * Returns wether or not the given object is a ParticleSystem.
107
+ * @param object defines the reference to the object to test its class name.
108
+ */
109
+ export declare function isParticleSystem(object: any): object is ParticleSystem;
110
+ /**
111
+ * Returns wether or not the given object is a GPUParticleSystem.
112
+ * @param object defines the reference to the object to test its class name.
113
+ */
114
+ export declare function isGPUParticleSystem(object: any): object is GPUParticleSystem;
115
+ /**
116
+ * Returns wether or not the given object is a IParticleSystem.
117
+ * @param object defines the reference to the object to test its class name.
118
+ */
119
+ export declare function isAnyParticleSystem(object: any): object is IParticleSystem;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "babylonjs-editor-tools",
3
- "version": "0.0.12",
4
- "description": "Babylon.js Editor Tools is a set of tools to help you create, edit and manage your Babylon.js scenes made using the Babylon.JS Editor",
3
+ "version": "5.0.0",
4
+ "description": "Babylon.js Editor Tools is a set of tools to help you create, edit and manage your Babylon.js scenes made using the Babylon.js Editor",
5
5
  "productName": "Babylon.js Editor Tools",
6
6
  "scripts": {
7
7
  "build": "tsc -p . && node esbuild.mjs",
@@ -23,8 +23,8 @@
23
23
  "@babel/core": "^7.26.10",
24
24
  "@babel/preset-env": "^7.26.9",
25
25
  "@babel/preset-typescript": "^7.27.0",
26
- "@babylonjs/core": "8.14.0",
27
- "@babylonjs/gui": "8.14.0",
26
+ "@babylonjs/core": "8.15.1",
27
+ "@babylonjs/gui": "8.15.1",
28
28
  "@types/jest": "^29.5.14",
29
29
  "babel-jest": "^29.7.0",
30
30
  "babel-plugin-transform-class-properties": "^6.24.1",