142765871ec44764369a4307cd59743f192b4c82b44350ea3dfb75e82f45d72b.json 12 KB

1
  1. {"ast":null,"code":"import { DeepCopier } from \"../../Misc/deepCopier.js\";\nimport { Vector3 } from \"../../Maths/math.vector.js\";\nimport { RandomRange } from \"../../Maths/math.scalar.functions.js\";\n/**\n * Particle emitter emitting particles from a point.\n * It emits the particles randomly between 2 given directions.\n */\nexport class PointParticleEmitter {\n /**\n * Creates a new instance PointParticleEmitter\n */\n constructor() {\n /**\n * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.\n */\n this.direction1 = new Vector3(0, 1.0, 0);\n /**\n * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.\n */\n this.direction2 = new Vector3(0, 1.0, 0);\n }\n /**\n * Called by the particle System when the direction is computed for the created particle.\n * @param worldMatrix is the world matrix of the particle system\n * @param directionToUpdate is the direction vector to update with the result\n * @param particle is the particle we are computed the direction for\n * @param isLocal defines if the direction should be set in local space\n */\n startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {\n const randX = RandomRange(this.direction1.x, this.direction2.x);\n const randY = RandomRange(this.direction1.y, this.direction2.y);\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\n if (isLocal) {\n directionToUpdate.copyFromFloats(randX, randY, randZ);\n return;\n }\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\n }\n /**\n * Called by the particle System when the position is computed for the created particle.\n * @param worldMatrix is the world matrix of the particle system\n * @param positionToUpdate is the position vector to update with the result\n * @param particle is the particle we are computed the position for\n * @param isLocal defines if the position should be set in local space\n */\n startPositionFunction(worldMatrix, positionToUpdate, particle, isLocal) {\n if (isLocal) {\n positionToUpdate.copyFromFloats(0, 0, 0);\n return;\n }\n Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);\n }\n /**\n * Clones the current emitter and returns a copy of it\n * @returns the new emitter\n */\n clone() {\n const newOne = new PointParticleEmitter();\n DeepCopier.DeepCopy(this, newOne);\n return newOne;\n }\n /**\n * Called by the GPUParticleSystem to setup the update shader\n * @param uboOrEffect defines the update shader\n */\n applyToShader(uboOrEffect) {\n uboOrEffect.setVector3(\"direction1\", this.direction1);\n uboOrEffect.setVector3(\"direction2\", this.direction2);\n }\n /**\n * Creates the structure of the ubo for this particle emitter\n * @param ubo ubo to create the structure for\n */\n buildUniformLayout(ubo) {\n ubo.addUniform(\"direction1\", 3);\n ubo.addUniform(\"direction2\", 3);\n }\n /**\n * Returns a string to use to update the GPU particles update shader\n * @returns a string containing the defines string\n */\n getEffectDefines() {\n return \"#define POINTEMITTER\";\n }\n /**\n * Returns the string \"PointParticleEmitter\"\n * @returns a string containing the class name\n */\n getClassName() {\n return \"PointParticleEmitter\";\n }\n /**\n * Serializes the particle system to a JSON object.\n * @returns the JSON object\n */\n serialize() {\n const serializationObject = {};\n serializationObject.type = this.getClassName();\n serializationObject.direction1 = this.direction1.asArray();\n serializationObject.direction2 = this.direction2.asArray();\n return serializationObject;\n }\n /**\n * Parse properties from a JSON object\n * @param serializationObject defines the JSON object\n */\n parse(serializationObject) {\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\n }\n}","map":{"version":3,"names":["DeepCopier","Vector3","RandomRange","PointParticleEmitter","constructor","direction1","direction2","startDirectionFunction","worldMatrix","directionToUpdate","particle","isLocal","randX","x","randY","y","randZ","z","copyFromFloats","TransformNormalFromFloatsToRef","startPositionFunction","positionToUpdate","TransformCoordinatesFromFloatsToRef","clone","newOne","DeepCopy","applyToShader","uboOrEffect","setVector3","buildUniformLayout","ubo","addUniform","getEffectDefines","getClassName","serialize","serializationObject","type","asArray","parse","FromArrayToRef"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Particles/EmitterTypes/pointParticleEmitter.js"],"sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier.js\";\nimport { Vector3 } from \"../../Maths/math.vector.js\";\nimport { RandomRange } from \"../../Maths/math.scalar.functions.js\";\n/**\n * Particle emitter emitting particles from a point.\n * It emits the particles randomly between 2 given directions.\n */\nexport class PointParticleEmitter {\n /**\n * Creates a new instance PointParticleEmitter\n */\n constructor() {\n /**\n * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.\n */\n this.direction1 = new Vector3(0, 1.0, 0);\n /**\n * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.\n */\n this.direction2 = new Vector3(0, 1.0, 0);\n }\n /**\n * Called by the particle System when the direction is computed for the created particle.\n * @param worldMatrix is the world matrix of the particle system\n * @param directionToUpdate is the direction vector to update with the result\n * @param particle is the particle we are computed the direction for\n * @param isLocal defines if the direction should be set in local space\n */\n startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {\n const randX = RandomRange(this.direction1.x, this.direction2.x);\n const randY = RandomRange(this.direction1.y, this.direction2.y);\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\n if (isLocal) {\n directionToUpdate.copyFromFloats(randX, randY, randZ);\n return;\n }\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\n }\n /**\n * Called by the particle System when the position is computed for the created particle.\n * @param worldMatrix is the world matrix of the particle system\n * @param positionToUpdate is the position vector to update with the result\n * @param particle is the particle we are computed the position for\n * @param isLocal defines if the position should be set in local space\n */\n startPositionFunction(worldMatrix, positionToUpdate, particle, isLocal) {\n if (isLocal) {\n positionToUpdate.copyFromFloats(0, 0, 0);\n return;\n }\n Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);\n }\n /**\n * Clones the current emitter and returns a copy of it\n * @returns the new emitter\n */\n clone() {\n const newOne = new PointParticleEmitter();\n DeepCopier.DeepCopy(this, newOne);\n return newOne;\n }\n /**\n * Called by the GPUParticleSystem to setup the update shader\n * @param uboOrEffect defines the update shader\n */\n applyToShader(uboOrEffect) {\n uboOrEffect.setVector3(\"direction1\", this.direction1);\n uboOrEffect.setVector3(\"direction2\", this.direction2);\n }\n /**\n * Creates the structure of the ubo for this particle emitter\n * @param ubo ubo to create the structure for\n */\n buildUniformLayout(ubo) {\n ubo.addUniform(\"direction1\", 3);\n ubo.addUniform(\"direction2\", 3);\n }\n /**\n * Returns a string to use to update the GPU particles update shader\n * @returns a string containing the defines string\n */\n getEffectDefines() {\n return \"#define POINTEMITTER\";\n }\n /**\n * Returns the string \"PointParticleEmitter\"\n * @returns a string containing the class name\n */\n getClassName() {\n return \"PointParticleEmitter\";\n }\n /**\n * Serializes the particle system to a JSON object.\n * @returns the JSON object\n */\n serialize() {\n const serializationObject = {};\n serializationObject.type = this.getClassName();\n serializationObject.direction1 = this.direction1.asArray();\n serializationObject.direction2 = this.direction2.asArray();\n return serializationObject;\n }\n /**\n * Parse properties from a JSON object\n * @param serializationObject defines the JSON object\n */\n parse(serializationObject) {\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,WAAW,QAAQ,sCAAsC;AAClE;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAC9B;AACJ;AACA;EACIC,WAAWA,CAAA,EAAG;IACV;AACR;AACA;IACQ,IAAI,CAACC,UAAU,GAAG,IAAIJ,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC;AACR;AACA;IACQ,IAAI,CAACK,UAAU,GAAG,IAAIL,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;EAC5C;EACA;AACJ;AACA;AACA;AACA;AACA;AACA;EACIM,sBAAsBA,CAACC,WAAW,EAAEC,iBAAiB,EAAEC,QAAQ,EAAEC,OAAO,EAAE;IACtE,MAAMC,KAAK,GAAGV,WAAW,CAAC,IAAI,CAACG,UAAU,CAACQ,CAAC,EAA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