@babylonjs/core 7.11.2 → 7.11.4
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.
- package/Animations/animatable.d.ts +10 -10
- package/Animations/animatable.js +5 -5
- package/Animations/animatable.js.map +1 -1
- package/Animations/animationGroupMask.d.ts +2 -2
- package/Animations/animationGroupMask.js +1 -1
- package/Animations/animationGroupMask.js.map +1 -1
- package/Animations/easing.d.ts +2 -2
- package/Animations/easing.js +1 -1
- package/Animations/easing.js.map +1 -1
- package/Behaviors/Meshes/attachToBoxBehavior.d.ts +3 -3
- package/Behaviors/Meshes/attachToBoxBehavior.js +3 -3
- package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.d.ts +2 -2
- package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.d.ts +2 -2
- package/Cameras/Inputs/freeCameraTouchInput.js +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Compute/computeEffect.js +21 -3
- package/Compute/computeEffect.js.map +1 -1
- package/Culling/Helper/IBoundingInfoHelperPlatform.d.ts +8 -0
- package/Culling/Helper/IBoundingInfoHelperPlatform.js +2 -0
- package/Culling/Helper/IBoundingInfoHelperPlatform.js.map +1 -0
- package/Culling/Helper/boundingInfoHelper.d.ts +32 -0
- package/Culling/Helper/boundingInfoHelper.js +48 -0
- package/Culling/Helper/boundingInfoHelper.js.map +1 -0
- package/Culling/Helper/computeShaderBoundingHelper.d.ts +34 -0
- package/Culling/Helper/computeShaderBoundingHelper.js +209 -0
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -0
- package/Culling/Helper/transformFeedbackBoundingHelper.d.ts +21 -0
- package/Culling/Helper/transformFeedbackBoundingHelper.js +197 -0
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -0
- package/Culling/Octrees/octree.d.ts +2 -2
- package/Culling/Octrees/octree.js +1 -1
- package/Culling/Octrees/octree.js.map +1 -1
- package/Culling/index.d.ts +3 -0
- package/Culling/index.js +3 -0
- package/Culling/index.js.map +1 -1
- package/Culling/ray.d.ts +4 -4
- package/Culling/ray.js +2 -2
- package/Culling/ray.js.map +1 -1
- package/Debug/skeletonViewer.d.ts +6 -6
- package/Debug/skeletonViewer.js +3 -3
- package/Debug/skeletonViewer.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.d.ts +2 -2
- package/DeviceInput/InputDevices/deviceSource.js +1 -1
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/Engines/Extensions/engine.transformFeedback.d.ts +5 -0
- package/Engines/Extensions/engine.transformFeedback.js +3 -0
- package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
- package/Engines/Processors/shaderProcessingOptions.d.ts +1 -1
- package/Engines/Processors/shaderProcessingOptions.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +2 -2
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.d.ts +7 -0
- package/Engines/nativeEngine.js +4 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Maths/math.color.d.ts +14 -14
- package/Maths/math.color.js +7 -7
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.isovector.d.ts +4 -4
- package/Maths/math.isovector.js +2 -2
- package/Maths/math.isovector.js.map +1 -1
- package/Maths/math.vector.d.ts +12 -12
- package/Maths/math.vector.js +6 -6
- package/Maths/math.vector.js.map +1 -1
- package/Maths/math.vertexFormat.d.ts +10 -10
- package/Maths/math.vertexFormat.js +5 -5
- package/Maths/math.vertexFormat.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +7 -0
- package/Meshes/abstractMesh.js +17 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +4 -0
- package/Meshes/mesh.js +13 -4
- package/Meshes/mesh.js.map +1 -1
- package/Misc/observable.d.ts +6 -6
- package/Misc/observable.js +4 -4
- package/Misc/observable.js.map +1 -1
- package/Misc/sceneOptimizer.d.ts +3 -3
- package/Misc/sceneOptimizer.js +2 -2
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +8 -4
- package/Morph/morphTargetManager.js +6 -3
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +2 -2
- package/Particles/EmitterTypes/coneParticleEmitter.js +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +8 -8
- package/Particles/EmitterTypes/cylinderParticleEmitter.js +4 -4
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.d.ts +6 -6
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js +3 -3
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +6 -6
- package/Particles/EmitterTypes/sphereParticleEmitter.js +3 -3
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/pointsCloudSystem.d.ts +0 -1
- package/Particles/pointsCloudSystem.js +0 -1
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Shaders/gpuTransform.fragment.d.ts +5 -0
- package/Shaders/gpuTransform.fragment.js +11 -0
- package/Shaders/gpuTransform.fragment.js.map +1 -0
- package/Shaders/gpuTransform.vertex.d.ts +13 -0
- package/Shaders/gpuTransform.vertex.js +33 -0
- package/Shaders/gpuTransform.vertex.js.map +1 -0
- package/ShadersWGSL/boundingInfo.compute.d.ts +5 -0
- package/ShadersWGSL/boundingInfo.compute.js +80 -0
- package/ShadersWGSL/boundingInfo.compute.js.map +1 -0
- package/XR/features/WebXRBackgroundRemover.d.ts +2 -2
- package/XR/features/WebXRBackgroundRemover.js +1 -1
- package/XR/features/WebXRBackgroundRemover.js.map +1 -1
- package/XR/features/WebXRHitTest.d.ts +2 -2
- package/XR/features/WebXRHitTest.js +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.d.ts +2 -2
- package/XR/features/WebXRHitTestLegacy.js +1 -1
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js +0 -2
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.d.ts +2 -0
- package/XR/motionController/webXRAbstractMotionController.js +1 -0
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morphTargetManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTargetManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAoD3B;;OAEG;IACH,IAAW,gBAAgB,CAAC,KAAc;QACtC,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;aAAM;YACH,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,aAAa,IAAI,CAAC,EAAE;gBACzB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;gBAEvB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;aACjC;SACJ;IACL,CAA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AK,CAAC,CAAC,CAAC;SAC1D;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AA/hBD,wFAAwF;AAC1E,uCAAoB,GAAG,IAAI,AAAP,CAAQ;AAE1C,qHAAqH;AACvG,6DAA0C,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { MorphTarget } from \"./morphTarget\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { RawTexture2DArray } from \"../Materials/Textures/rawTexture2DArray\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\n/**\r\n * This class is used to deform meshes using morphing between different targets\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTargetManager implements IDisposable {\r\n /** Enable storing morph target data into textures when set to true (true by default) */\r\n public static EnableTextureStorage = true;\r\n\r\n /** Maximum number of active morph targets supported in the \"vertex attribute\" mode (i.e., not the \"texture\" mode) */\r\n public static MaxActiveMorphTargetsInVertexAttributeMode = 8;\r\n\r\n private _targets = new Array<MorphTarget>();\r\n private _targetInfluenceChangedObservers = new Array<Nullable<Observer<boolean>>>();\r\n private _targetDataLayoutChangedObservers = new Array<Nullable<Observer<void>>>();\r\n private _activeTargets = new SmartArray<MorphTarget>(16);\r\n private _scene: Nullable<Scene>;\r\n private _influences: Float32Array;\r\n private _morphTargetTextureIndices: Float32Array;\r\n private _supportsNormals = false;\r\n private _supportsTangents = false;\r\n private _supportsUVs = false;\r\n private _vertexCount = 0;\r\n private _textureVertexStride = 0;\r\n private _textureWidth = 0;\r\n private _textureHeight = 1;\r\n private _uniqueId = 0;\r\n private _tempInfluences = new Array<number>();\r\n private _canUseTextureForTargets = false;\r\n private _blockCounter = 0;\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n /** @internal */\r\n public _targetStoreTexture: Nullable<RawTexture2DArray>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if influencers must be optimized (eg. recompiling the shader if less influencers are used)\r\n */\r\n public optimizeInfluencers = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if normals must be morphed\r\n */\r\n public enableNormalMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if tangents must be morphed\r\n */\r\n public enableTangentMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if UV must be morphed\r\n */\r\n public enableUVMorphing = true;\r\n\r\n /**\r\n * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers\r\n */\r\n public set areUpdatesFrozen(block: boolean) {\r\n if (block) {\r\n this._blockCounter++;\r\n } else {\r\n this._blockCounter--;\r\n if (this._blockCounter <= 0) {\r\n this._blockCounter = 0;\r\n\r\n this._syncActiveTargets(true);\r\n }\r\n }\r\n }\r\n\r\n public get areUpdatesFrozen() {\r\n return this._blockCounter > 0;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTargetManager\r\n * @param scene defines the current scene\r\n */\r\n public constructor(scene: Nullable<Scene> = null) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n this._scene = scene;\r\n\r\n if (this._scene) {\r\n this._scene.addMorphTargetManager(this);\r\n\r\n this._uniqueId = this._scene.getUniqueId();\r\n\r\n const engineCaps = this._scene.getEngine().getCaps();\r\n this._canUseTextureForTargets =\r\n engineCaps.canUseGLVertexID && engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0 && engineCaps.texture2DArrayMaxLayerCount > 1;\r\n }\r\n }\r\n\r\n private _numMaxInfluencers = 0;\r\n\r\n /**\r\n * Gets or sets the maximum number of influencers (targets) (default value: 0).\r\n * Setting a value for this property can lead to a smoother experience, as only one shader will be compiled, which will use this value as the maximum number of influencers.\r\n * If you leave the value at 0 (default), a new shader will be compiled every time the number of active influencers changes. This can cause problems, as compiling a shader takes time.\r\n * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.\r\n * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.\r\n * Note that this property has no effect if \"useTextureToStoreTargets\" is false.\r\n */\r\n public get numMaxInfluencers(): number {\r\n return this._numMaxInfluencers;\r\n }\r\n\r\n public set numMaxInfluencers(value: number) {\r\n if (this._numMaxInfluencers === value) {\r\n return;\r\n }\r\n\r\n this._numMaxInfluencers = value;\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets the number of vertices handled by this manager\r\n */\r\n public get vertexCount(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of normals\r\n */\r\n public get supportsNormals(): boolean {\r\n return this._supportsNormals && this.enableNormalMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of tangents\r\n */\r\n public get supportsTangents(): boolean {\r\n return this._supportsTangents && this.enableTangentMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of texture coordinates\r\n */\r\n public get supportsUVs(): boolean {\r\n return this._supportsUVs && this.enableUVMorphing;\r\n }\r\n\r\n /**\r\n * Gets the number of targets stored in this manager\r\n */\r\n public get numTargets(): number {\r\n return this._targets.length;\r\n }\r\n\r\n /**\r\n * Gets the number of influencers (ie. the number of targets with influences > 0)\r\n */\r\n public get numInfluencers(): number {\r\n return this._activeTargets.length;\r\n }\r\n\r\n /**\r\n * Gets the list of influences (one per target)\r\n */\r\n public get influences(): Float32Array {\r\n return this._influences;\r\n }\r\n\r\n private _useTextureToStoreTargets = true;\r\n /**\r\n * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).\r\n * Please note that this option is not available if the hardware does not support it\r\n */\r\n public get useTextureToStoreTargets(): boolean {\r\n return this._useTextureToStoreTargets;\r\n }\r\n\r\n public set useTextureToStoreTargets(value: boolean) {\r\n this._useTextureToStoreTargets = value;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)\r\n */\r\n public get isUsingTextureForTargets() {\r\n return (\r\n MorphTargetManager.EnableTextureStorage &&\r\n this.useTextureToStoreTargets &&\r\n this._canUseTextureForTargets &&\r\n !this._scene?.getEngine().getCaps().disableMorphTargetTexture\r\n );\r\n }\r\n\r\n /**\r\n * Gets the active target at specified index. An active target is a target with an influence > 0\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getActiveTarget(index: number): MorphTarget {\r\n return this._activeTargets.data[index];\r\n }\r\n\r\n /**\r\n * Gets the target at specified index\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getTarget(index: number): MorphTarget {\r\n return this._targets[index];\r\n }\r\n\r\n /**\r\n * Gets the first target with the specified name\r\n * @param name defines the name to check\r\n * @returns the requested target\r\n */\r\n public getTargetByName(name: string): Nullable<MorphTarget> {\r\n for (const target of this._targets) {\r\n if (target.name === name) {\r\n return target;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Add a new target to this manager\r\n * @param target defines the target to add\r\n */\r\n public addTarget(target: MorphTarget): void {\r\n this._targets.push(target);\r\n this._targetInfluenceChangedObservers.push(\r\n target.onInfluenceChanged.add((needUpdate) => {\r\n this._syncActiveTargets(needUpdate);\r\n })\r\n );\r\n this._targetDataLayoutChangedObservers.push(\r\n target._onDataLayoutChanged.add(() => {\r\n this._syncActiveTargets(true);\r\n })\r\n );\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Removes a target from the manager\r\n * @param target defines the target to remove\r\n */\r\n public removeTarget(target: MorphTarget): void {\r\n const index = this._targets.indexOf(target);\r\n if (index >= 0) {\r\n this._targets.splice(index, 1);\r\n\r\n target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);\r\n target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n if (this._scene) {\r\n this._scene.stopAnimation(target);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _bind(effect: Effect) {\r\n effect.setFloat3(\"morphTargetTextureInfo\", this._textureVertexStride, this._textureWidth, this._textureHeight);\r\n effect.setFloatArray(\"morphTargetTextureIndices\", this._morphTargetTextureIndices);\r\n effect.setTexture(\"morphTargets\", this._targetStoreTexture);\r\n effect.setInt(\"morphTargetCount\", this.numInfluencers);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new MorphTargetManager\r\n */\r\n public clone(): MorphTargetManager {\r\n const copy = new MorphTargetManager(this._scene);\r\n\r\n for (const target of this._targets) {\r\n copy.addTarget(target.clone());\r\n }\r\n\r\n copy.enableNormalMorphing = this.enableNormalMorphing;\r\n copy.enableTangentMorphing = this.enableTangentMorphing;\r\n copy.enableUVMorphing = this.enableUVMorphing;\r\n\r\n return copy;\r\n }\r\n\r\n /**\r\n * Serializes the current manager into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.id = this.uniqueId;\r\n\r\n serializationObject.targets = [];\r\n for (const target of this._targets) {\r\n serializationObject.targets.push(target.serialize());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n private _syncActiveTargets(needUpdate: boolean): void {\r\n if (this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n let influenceCount = 0;\r\n this._activeTargets.reset();\r\n this._supportsNormals = true;\r\n this._supportsTangents = true;\r\n this._supportsUVs = true;\r\n this._vertexCount = 0;\r\n\r\n if (this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount) {\r\n this.useTextureToStoreTargets = false;\r\n }\r\n\r\n if (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) {\r\n this._morphTargetTextureIndices = new Float32Array(this._targets.length);\r\n }\r\n\r\n let targetIndex = -1;\r\n for (const target of this._targets) {\r\n targetIndex++;\r\n if (target.influence === 0 && this.optimizeInfluencers) {\r\n continue;\r\n }\r\n\r\n if (this._activeTargets.length >= MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode && !this.isUsingTextureForTargets) {\r\n break;\r\n }\r\n\r\n this._activeTargets.push(target);\r\n this._morphTargetTextureIndices[influenceCount] = targetIndex;\r\n this._tempInfluences[influenceCount++] = target.influence;\r\n\r\n this._supportsNormals = this._supportsNormals && target.hasNormals;\r\n this._supportsTangents = this._supportsTangents && target.hasTangents;\r\n this._supportsUVs = this._supportsUVs && target.hasUVs;\r\n\r\n const positions = target.getPositions();\r\n if (positions) {\r\n const vertexCount = positions.length / 3;\r\n if (this._vertexCount === 0) {\r\n this._vertexCount = vertexCount;\r\n } else if (this._vertexCount !== vertexCount) {\r\n Logger.Error(\"Incompatible target. Targets must all have the same vertices count.\");\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (this._morphTargetTextureIndices.length !== influenceCount) {\r\n this._morphTargetTextureIndices = this._morphTargetTextureIndices.slice(0, influenceCount);\r\n }\r\n\r\n if (!this._influences || this._influences.length !== influenceCount) {\r\n this._influences = new Float32Array(influenceCount);\r\n }\r\n\r\n for (let index = 0; index < influenceCount; index++) {\r\n this._influences[index] = this._tempInfluences[index];\r\n }\r\n\r\n if (needUpdate) {\r\n this.synchronize();\r\n }\r\n }\r\n\r\n /**\r\n * Synchronize the targets with all the meshes using this morph target manager\r\n */\r\n public synchronize(): void {\r\n if (!this._scene || this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n if (this.isUsingTextureForTargets && (this._vertexCount || this.numMaxInfluencers > 0)) {\r\n this._textureVertexStride = 1;\r\n\r\n if (this._supportsNormals) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsTangents) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsUVs) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n this._textureWidth = this._vertexCount * this._textureVertexStride || 1;\r\n this._textureHeight = 1;\r\n\r\n const maxTextureSize = this._scene.getEngine().getCaps().maxTextureSize;\r\n if (this._textureWidth > maxTextureSize) {\r\n this._textureHeight = Math.ceil(this._textureWidth / maxTextureSize);\r\n this._textureWidth = maxTextureSize;\r\n }\r\n\r\n let mustUpdateTexture = true;\r\n if (this._targetStoreTexture) {\r\n const textureSize = this._targetStoreTexture.getSize();\r\n if (textureSize.width === this._textureWidth && textureSize.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length) {\r\n mustUpdateTexture = false;\r\n }\r\n }\r\n\r\n if (mustUpdateTexture) {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n const targetCount = this._targets.length;\r\n const data = new Float32Array(targetCount * this._textureWidth * this._textureHeight * 4);\r\n\r\n let offset = 0;\r\n for (let index = 0; index < targetCount; index++) {\r\n const target = this._targets[index];\r\n\r\n const positions = target.getPositions();\r\n const normals = target.getNormals();\r\n const uvs = target.getUVs();\r\n const tangents = target.getTangents();\r\n\r\n if (!positions) {\r\n if (index === 0) {\r\n Logger.Error(\"Invalid morph target. Target must have positions.\");\r\n }\r\n return;\r\n }\r\n\r\n offset = index * this._textureWidth * this._textureHeight * 4;\r\n for (let vertex = 0; vertex < this._vertexCount; vertex++) {\r\n data[offset] = positions[vertex * 3];\r\n data[offset + 1] = positions[vertex * 3 + 1];\r\n data[offset + 2] = positions[vertex * 3 + 2];\r\n\r\n offset += 4;\r\n\r\n if (this._supportsNormals && normals) {\r\n data[offset] = normals[vertex * 3];\r\n data[offset + 1] = normals[vertex * 3 + 1];\r\n data[offset + 2] = normals[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsUVs && uvs) {\r\n data[offset] = uvs[vertex * 2];\r\n data[offset + 1] = uvs[vertex * 2 + 1];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsTangents && tangents) {\r\n data[offset] = tangents[vertex * 3];\r\n data[offset + 1] = tangents[vertex * 3 + 1];\r\n data[offset + 2] = tangents[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n }\r\n }\r\n\r\n this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(\r\n data,\r\n this._textureWidth,\r\n this._textureHeight,\r\n targetCount,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n }\r\n }\r\n\r\n // Flag meshes as dirty to resync with the active targets\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).morphTargetManager === this) {\r\n (<Mesh>mesh)._syncGeometryWithMorphTargetManager();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose() {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n this._targetStoreTexture = null;\r\n\r\n // Remove from scene\r\n if (this._scene) {\r\n this._scene.removeMorphTargetManager(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.morphTargetManagers.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.morphTargetManagers.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n for (const morph of this._targets) {\r\n this._scene.stopAnimation(morph);\r\n }\r\n }\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new MorphTargetManager from serialized data\r\n * @param serializationObject defines the serialized data\r\n * @param scene defines the hosting scene\r\n * @returns the new MorphTargetManager\r\n */\r\n public static Parse(serializationObject: any, scene: Scene): MorphTargetManager {\r\n const result = new MorphTargetManager(scene);\r\n\r\n result._uniqueId = serializationObject.id;\r\n\r\n for (const targetData of serializationObject.targets) {\r\n result.addTarget(MorphTarget.Parse(targetData, scene));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"morphTargetManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTargetManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IA4D3B;;OAEG;IACH,IAAW,gBAAgB,CAAC,KAAc;QACtC,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;aAAM;YACH,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,aAAa,IAAI,CAAC,EAAE;gBACzB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;gBAEvB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;aACjC;SACJ;IACL,CAAC;IAED,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,YAAmB,QAAyB,IAAI;QA7ExC,aAAQ,GAAG,IAAI,KAAK,EAAe,CAAC;QACpC,qCAAgC,GAAG,IAAI,KAAK,EAA+B,CAAC;QAC5E,sCAAiC,GAAG,IAAI,KAAK,EAA4B,CAAC;QAC1E,mBAAc,GAAG,IAAI,UAAU,CAAc,EAAE,CAAC,CAAC;QAGjD,qBAAgB,GAAG,KAAK,CAAC;QACzB,sBAAiB,GAAG,KAAK,CAAC;QAC1B,iBAAY,GAAG,KAAK,CAAC;Q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AM,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;YAE3C,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACvB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACtE,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;oBACZ,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC9D;gBACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;aAChC;YAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aACpC;SACJ;IACL,CAAC;IAED,UAAU;IAEV;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,mBAAwB,EAAE,KAAY;QACtD,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE7C,MAAM,CAAC,SAAS,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAE1C,KAAK,MAAM,UAAU,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAClD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;SAC1D;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AAviBD,wFAAwF;AAC1E,uCAAoB,GAAG,IAAI,AAAP,CAAQ;AAE1C,qHAAqH;AACvG,6DAA0C,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { MorphTarget } from \"./morphTarget\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { RawTexture2DArray } from \"../Materials/Textures/rawTexture2DArray\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\n/**\r\n * This class is used to deform meshes using morphing between different targets\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTargetManager implements IDisposable {\r\n /** Enable storing morph target data into textures when set to true (true by default) */\r\n public static EnableTextureStorage = true;\r\n\r\n /** Maximum number of active morph targets supported in the \"vertex attribute\" mode (i.e., not the \"texture\" mode) */\r\n public static MaxActiveMorphTargetsInVertexAttributeMode = 8;\r\n\r\n private _targets = new Array<MorphTarget>();\r\n private _targetInfluenceChangedObservers = new Array<Nullable<Observer<boolean>>>();\r\n private _targetDataLayoutChangedObservers = new Array<Nullable<Observer<void>>>();\r\n private _activeTargets = new SmartArray<MorphTarget>(16);\r\n private _scene: Nullable<Scene>;\r\n private _influences: Float32Array;\r\n private _supportsNormals = false;\r\n private _supportsTangents = false;\r\n private _supportsUVs = false;\r\n private _vertexCount = 0;\r\n private _uniqueId = 0;\r\n private _tempInfluences = new Array<number>();\r\n private _canUseTextureForTargets = false;\r\n private _blockCounter = 0;\r\n\r\n /** @internal */\r\n public _textureVertexStride = 0;\r\n\r\n /** @internal */\r\n public _textureWidth = 0;\r\n\r\n /** @internal */\r\n public _textureHeight = 1;\r\n\r\n /** @internal */\r\n public _morphTargetTextureIndices: Float32Array;\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n /** @internal */\r\n public _targetStoreTexture: Nullable<RawTexture2DArray>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if influencers must be optimized (eg. recompiling the shader if less influencers are used)\r\n */\r\n public optimizeInfluencers = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if normals must be morphed\r\n */\r\n public enableNormalMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if tangents must be morphed\r\n */\r\n public enableTangentMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if UV must be morphed\r\n */\r\n public enableUVMorphing = true;\r\n\r\n /**\r\n * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers\r\n */\r\n public set areUpdatesFrozen(block: boolean) {\r\n if (block) {\r\n this._blockCounter++;\r\n } else {\r\n this._blockCounter--;\r\n if (this._blockCounter <= 0) {\r\n this._blockCounter = 0;\r\n\r\n this._syncActiveTargets(true);\r\n }\r\n }\r\n }\r\n\r\n public get areUpdatesFrozen() {\r\n return this._blockCounter > 0;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTargetManager\r\n * @param scene defines the current scene\r\n */\r\n public constructor(scene: Nullable<Scene> = null) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n this._scene = scene;\r\n\r\n if (this._scene) {\r\n this._scene.addMorphTargetManager(this);\r\n\r\n this._uniqueId = this._scene.getUniqueId();\r\n\r\n const engineCaps = this._scene.getEngine().getCaps();\r\n this._canUseTextureForTargets =\r\n engineCaps.canUseGLVertexID && engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0 && engineCaps.texture2DArrayMaxLayerCount > 1;\r\n }\r\n }\r\n\r\n private _numMaxInfluencers = 0;\r\n\r\n /**\r\n * Gets or sets the maximum number of influencers (targets) (default value: 0).\r\n * Setting a value for this property can lead to a smoother experience, as only one shader will be compiled, which will use this value as the maximum number of influencers.\r\n * If you leave the value at 0 (default), a new shader will be compiled every time the number of active influencers changes. This can cause problems, as compiling a shader takes time.\r\n * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.\r\n * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.\r\n * Note that this property has no effect if \"useTextureToStoreTargets\" is false.\r\n */\r\n public get numMaxInfluencers(): number {\r\n return this._numMaxInfluencers;\r\n }\r\n\r\n public set numMaxInfluencers(value: number) {\r\n if (this._numMaxInfluencers === value) {\r\n return;\r\n }\r\n\r\n this._numMaxInfluencers = value;\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets the number of vertices handled by this manager\r\n */\r\n public get vertexCount(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of normals\r\n */\r\n public get supportsNormals(): boolean {\r\n return this._supportsNormals && this.enableNormalMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of tangents\r\n */\r\n public get supportsTangents(): boolean {\r\n return this._supportsTangents && this.enableTangentMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of texture coordinates\r\n */\r\n public get supportsUVs(): boolean {\r\n return this._supportsUVs && this.enableUVMorphing;\r\n }\r\n\r\n /**\r\n * Gets the number of targets stored in this manager\r\n */\r\n public get numTargets(): number {\r\n return this._targets.length;\r\n }\r\n\r\n /**\r\n * Gets the number of influencers (ie. the number of targets with influences > 0)\r\n */\r\n public get numInfluencers(): number {\r\n return this._activeTargets.length;\r\n }\r\n\r\n /**\r\n * Gets the list of influences (one per target)\r\n */\r\n public get influences(): Float32Array {\r\n return this._influences;\r\n }\r\n\r\n private _useTextureToStoreTargets = true;\r\n /**\r\n * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).\r\n * Please note that this option is not available if the hardware does not support it\r\n */\r\n public get useTextureToStoreTargets(): boolean {\r\n return this._useTextureToStoreTargets;\r\n }\r\n\r\n public set useTextureToStoreTargets(value: boolean) {\r\n this._useTextureToStoreTargets = value;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)\r\n */\r\n public get isUsingTextureForTargets() {\r\n return (\r\n MorphTargetManager.EnableTextureStorage &&\r\n this.useTextureToStoreTargets &&\r\n this._canUseTextureForTargets &&\r\n !this._scene?.getEngine().getCaps().disableMorphTargetTexture\r\n );\r\n }\r\n\r\n /**\r\n * Gets the active target at specified index. An active target is a target with an influence > 0\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getActiveTarget(index: number): MorphTarget {\r\n return this._activeTargets.data[index];\r\n }\r\n\r\n /**\r\n * Gets the target at specified index\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getTarget(index: number): MorphTarget {\r\n return this._targets[index];\r\n }\r\n\r\n /**\r\n * Gets the first target with the specified name\r\n * @param name defines the name to check\r\n * @returns the requested target\r\n */\r\n public getTargetByName(name: string): Nullable<MorphTarget> {\r\n for (const target of this._targets) {\r\n if (target.name === name) {\r\n return target;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Add a new target to this manager\r\n * @param target defines the target to add\r\n */\r\n public addTarget(target: MorphTarget): void {\r\n this._targets.push(target);\r\n this._targetInfluenceChangedObservers.push(\r\n target.onInfluenceChanged.add((needUpdate) => {\r\n this._syncActiveTargets(needUpdate);\r\n })\r\n );\r\n this._targetDataLayoutChangedObservers.push(\r\n target._onDataLayoutChanged.add(() => {\r\n this._syncActiveTargets(true);\r\n })\r\n );\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Removes a target from the manager\r\n * @param target defines the target to remove\r\n */\r\n public removeTarget(target: MorphTarget): void {\r\n const index = this._targets.indexOf(target);\r\n if (index >= 0) {\r\n this._targets.splice(index, 1);\r\n\r\n target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);\r\n target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n if (this._scene) {\r\n this._scene.stopAnimation(target);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _bind(effect: Effect) {\r\n effect.setFloat3(\"morphTargetTextureInfo\", this._textureVertexStride, this._textureWidth, this._textureHeight);\r\n effect.setFloatArray(\"morphTargetTextureIndices\", this._morphTargetTextureIndices);\r\n effect.setTexture(\"morphTargets\", this._targetStoreTexture);\r\n effect.setInt(\"morphTargetCount\", this.numInfluencers);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new MorphTargetManager\r\n */\r\n public clone(): MorphTargetManager {\r\n const copy = new MorphTargetManager(this._scene);\r\n\r\n for (const target of this._targets) {\r\n copy.addTarget(target.clone());\r\n }\r\n\r\n copy.enableNormalMorphing = this.enableNormalMorphing;\r\n copy.enableTangentMorphing = this.enableTangentMorphing;\r\n copy.enableUVMorphing = this.enableUVMorphing;\r\n\r\n return copy;\r\n }\r\n\r\n /**\r\n * Serializes the current manager into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.id = this.uniqueId;\r\n\r\n serializationObject.targets = [];\r\n for (const target of this._targets) {\r\n serializationObject.targets.push(target.serialize());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n private _syncActiveTargets(needUpdate: boolean): void {\r\n if (this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n let influenceCount = 0;\r\n this._activeTargets.reset();\r\n this._supportsNormals = true;\r\n this._supportsTangents = true;\r\n this._supportsUVs = true;\r\n this._vertexCount = 0;\r\n\r\n if (this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount) {\r\n this.useTextureToStoreTargets = false;\r\n }\r\n\r\n if (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) {\r\n this._morphTargetTextureIndices = new Float32Array(this._targets.length);\r\n }\r\n\r\n let targetIndex = -1;\r\n for (const target of this._targets) {\r\n targetIndex++;\r\n if (target.influence === 0 && this.optimizeInfluencers) {\r\n continue;\r\n }\r\n\r\n if (this._activeTargets.length >= MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode && !this.isUsingTextureForTargets) {\r\n break;\r\n }\r\n\r\n this._activeTargets.push(target);\r\n this._morphTargetTextureIndices[influenceCount] = targetIndex;\r\n this._tempInfluences[influenceCount++] = target.influence;\r\n\r\n this._supportsNormals = this._supportsNormals && target.hasNormals;\r\n this._supportsTangents = this._supportsTangents && target.hasTangents;\r\n this._supportsUVs = this._supportsUVs && target.hasUVs;\r\n\r\n const positions = target.getPositions();\r\n if (positions) {\r\n const vertexCount = positions.length / 3;\r\n if (this._vertexCount === 0) {\r\n this._vertexCount = vertexCount;\r\n } else if (this._vertexCount !== vertexCount) {\r\n Logger.Error(\"Incompatible target. Targets must all have the same vertices count.\");\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (this._morphTargetTextureIndices.length !== influenceCount) {\r\n this._morphTargetTextureIndices = this._morphTargetTextureIndices.slice(0, influenceCount);\r\n }\r\n\r\n if (!this._influences || this._influences.length !== influenceCount) {\r\n this._influences = new Float32Array(influenceCount);\r\n }\r\n\r\n for (let index = 0; index < influenceCount; index++) {\r\n this._influences[index] = this._tempInfluences[index];\r\n }\r\n\r\n if (needUpdate) {\r\n this.synchronize();\r\n }\r\n }\r\n\r\n /**\r\n * Synchronize the targets with all the meshes using this morph target manager\r\n */\r\n public synchronize(): void {\r\n if (!this._scene || this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n if (this.isUsingTextureForTargets && (this._vertexCount || this.numMaxInfluencers > 0)) {\r\n this._textureVertexStride = 1;\r\n\r\n if (this._supportsNormals) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsTangents) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsUVs) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n this._textureWidth = this._vertexCount * this._textureVertexStride || 1;\r\n this._textureHeight = 1;\r\n\r\n const maxTextureSize = this._scene.getEngine().getCaps().maxTextureSize;\r\n if (this._textureWidth > maxTextureSize) {\r\n this._textureHeight = Math.ceil(this._textureWidth / maxTextureSize);\r\n this._textureWidth = maxTextureSize;\r\n }\r\n\r\n let mustUpdateTexture = true;\r\n if (this._targetStoreTexture) {\r\n const textureSize = this._targetStoreTexture.getSize();\r\n if (textureSize.width === this._textureWidth && textureSize.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length) {\r\n mustUpdateTexture = false;\r\n }\r\n }\r\n\r\n if (mustUpdateTexture) {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n const targetCount = this._targets.length;\r\n const data = new Float32Array(targetCount * this._textureWidth * this._textureHeight * 4);\r\n\r\n let offset = 0;\r\n for (let index = 0; index < targetCount; index++) {\r\n const target = this._targets[index];\r\n\r\n const positions = target.getPositions();\r\n const normals = target.getNormals();\r\n const uvs = target.getUVs();\r\n const tangents = target.getTangents();\r\n\r\n if (!positions) {\r\n if (index === 0) {\r\n Logger.Error(\"Invalid morph target. Target must have positions.\");\r\n }\r\n return;\r\n }\r\n\r\n offset = index * this._textureWidth * this._textureHeight * 4;\r\n for (let vertex = 0; vertex < this._vertexCount; vertex++) {\r\n data[offset] = positions[vertex * 3];\r\n data[offset + 1] = positions[vertex * 3 + 1];\r\n data[offset + 2] = positions[vertex * 3 + 2];\r\n\r\n offset += 4;\r\n\r\n if (this._supportsNormals && normals) {\r\n data[offset] = normals[vertex * 3];\r\n data[offset + 1] = normals[vertex * 3 + 1];\r\n data[offset + 2] = normals[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsUVs && uvs) {\r\n data[offset] = uvs[vertex * 2];\r\n data[offset + 1] = uvs[vertex * 2 + 1];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsTangents && tangents) {\r\n data[offset] = tangents[vertex * 3];\r\n data[offset + 1] = tangents[vertex * 3 + 1];\r\n data[offset + 2] = tangents[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n }\r\n }\r\n\r\n this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(\r\n data,\r\n this._textureWidth,\r\n this._textureHeight,\r\n targetCount,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n }\r\n }\r\n\r\n // Flag meshes as dirty to resync with the active targets\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).morphTargetManager === this) {\r\n (<Mesh>mesh)._syncGeometryWithMorphTargetManager();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose() {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n this._targetStoreTexture = null;\r\n\r\n // Remove from scene\r\n if (this._scene) {\r\n this._scene.removeMorphTargetManager(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.morphTargetManagers.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.morphTargetManagers.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n for (const morph of this._targets) {\r\n this._scene.stopAnimation(morph);\r\n }\r\n }\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new MorphTargetManager from serialized data\r\n * @param serializationObject defines the serialized data\r\n * @param scene defines the hosting scene\r\n * @returns the new MorphTargetManager\r\n */\r\n public static Parse(serializationObject: any, scene: Scene): MorphTargetManager {\r\n const result = new MorphTargetManager(scene);\r\n\r\n result._uniqueId = serializationObject.id;\r\n\r\n for (const targetData of serializationObject.targets) {\r\n result.addTarget(MorphTarget.Parse(targetData, scene));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -10,7 +10,7 @@ import type { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
|
10
10
|
* The emission direction might be randomized.
|
|
11
11
|
*/
|
|
12
12
|
export declare class ConeParticleEmitter implements IParticleEmitterType {
|
|
13
|
-
/** defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
13
|
+
/** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
14
14
|
directionRandomizer: number;
|
|
15
15
|
private _radius;
|
|
16
16
|
private _angle;
|
|
@@ -45,7 +45,7 @@ export declare class ConeParticleEmitter implements IParticleEmitterType {
|
|
|
45
45
|
* @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
|
|
46
46
|
*/
|
|
47
47
|
constructor(radius?: number, angle?: number,
|
|
48
|
-
/** defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
48
|
+
/** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
49
49
|
directionRandomizer?: number);
|
|
50
50
|
/**
|
|
51
51
|
* Called by the particle System when the direction is computed for the created particle.
|
|
@@ -42,7 +42,7 @@ export class ConeParticleEmitter {
|
|
|
42
42
|
* @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
|
|
43
43
|
*/
|
|
44
44
|
constructor(radius = 1, angle = Math.PI,
|
|
45
|
-
/** defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
45
|
+
/** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
|
|
46
46
|
directionRandomizer = 0) {
|
|
47
47
|
this.directionRandomizer = directionRandomizer;
|
|
48
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,Y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AE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n if (isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle._localPosition!).normalize();\r\n } else {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = Scalar.RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = Scalar.RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACv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AmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n if (isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle._localPosition!).normalize();\r\n } else {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = Scalar.RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = Scalar.RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
|
|
@@ -10,19 +10,19 @@ import type { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class CylinderParticleEmitter implements IParticleEmitterType {
|
|
12
12
|
/**
|
|
13
|
-
* The radius of the emission cylinder.
|
|
13
|
+
* [1] The radius of the emission cylinder.
|
|
14
14
|
*/
|
|
15
15
|
radius: number;
|
|
16
16
|
/**
|
|
17
|
-
* The height of the emission cylinder.
|
|
17
|
+
* [1] The height of the emission cylinder.
|
|
18
18
|
*/
|
|
19
19
|
height: number;
|
|
20
20
|
/**
|
|
21
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
21
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
22
22
|
*/
|
|
23
23
|
radiusRange: number;
|
|
24
24
|
/**
|
|
25
|
-
* How much to randomize the particle direction [0-1].
|
|
25
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
26
26
|
*/
|
|
27
27
|
directionRandomizer: number;
|
|
28
28
|
private _tempVector;
|
|
@@ -35,19 +35,19 @@ export declare class CylinderParticleEmitter implements IParticleEmitterType {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(
|
|
37
37
|
/**
|
|
38
|
-
* The radius of the emission cylinder.
|
|
38
|
+
* [1] The radius of the emission cylinder.
|
|
39
39
|
*/
|
|
40
40
|
radius?: number,
|
|
41
41
|
/**
|
|
42
|
-
* The height of the emission cylinder.
|
|
42
|
+
* [1] The height of the emission cylinder.
|
|
43
43
|
*/
|
|
44
44
|
height?: number,
|
|
45
45
|
/**
|
|
46
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
46
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
47
47
|
*/
|
|
48
48
|
radiusRange?: number,
|
|
49
49
|
/**
|
|
50
|
-
* How much to randomize the particle direction [0-1].
|
|
50
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
51
51
|
*/
|
|
52
52
|
directionRandomizer?: number);
|
|
53
53
|
/**
|
|
@@ -15,19 +15,19 @@ export class CylinderParticleEmitter {
|
|
|
15
15
|
*/
|
|
16
16
|
constructor(
|
|
17
17
|
/**
|
|
18
|
-
* The radius of the emission cylinder.
|
|
18
|
+
* [1] The radius of the emission cylinder.
|
|
19
19
|
*/
|
|
20
20
|
radius = 1,
|
|
21
21
|
/**
|
|
22
|
-
* The height of the emission cylinder.
|
|
22
|
+
* [1] The height of the emission cylinder.
|
|
23
23
|
*/
|
|
24
24
|
height = 1,
|
|
25
25
|
/**
|
|
26
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
26
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
27
27
|
*/
|
|
28
28
|
radiusRange = 1,
|
|
29
29
|
/**
|
|
30
|
-
* How much to randomize the particle direction [0-1].
|
|
30
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
31
31
|
*/
|
|
32
32
|
directionRandomizer = 0) {
|
|
33
33
|
this.radius = radius;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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AU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/E,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cylinder.\r\n * It emits the particles alongside the cylinder radius. The emission direction might be randomized.\r\n */\r\nexport class CylinderParticleEmitter implements IParticleEmitterType {\r\n private _tempVector = Vector3.Zero();\r\n\r\n /**\r\n * Creates a new instance CylinderParticleEmitter\r\n * @param radius the radius of the emission cylinder (1 by default)\r\n * @param height the height of the emission cylinder (1 by default)\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * The radius of the emission cylinder.\r\n */\r\n public radius = 1,\r\n /**\r\n * The height of the emission cylinder.\r\n */\r\n public height = 1,\r\n /**\r\n * The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n * @param inverseWorldMatrix defines the inverted world matrix to use if isLocal is false\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean, inverseWorldMatrix: Matrix): void {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), this._tempVector);\r\n\r\n this._tempVector.normalize();\r\n\r\n Vector3.TransformNormalToRef(this._tempVector, inverseWorldMatrix, this._tempVector);\r\n\r\n const randY = Scalar.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += Scalar.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(this._tempVector);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const yPos = Scalar.RandomRange(-this.height / 2, this.height / 2);\r\n const angle = Scalar.RandomRange(0, 2 * Math.PI);\r\n\r\n // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html\r\n const radiusDistribution = Scalar.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * this.radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(xPos, yPos, zPos);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): CylinderParticleEmitter {\r\n const newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"height\", this.height);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"height\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define CYLINDEREMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"CylinderParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"CylinderParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.height = this.height;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.height = serializationObject.height;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a cylinder.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {\r\n /**\r\n * Creates a new instance CylinderDirectedParticleEmitter\r\n * @param radius the radius of the emission cylinder (1 by default)\r\n * @param height the height of the emission cylinder (1 by default)\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n height = 1,\r\n radiusRange = 1,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, height, radiusRange);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param _particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, _particle: Particle, isLocal: boolean): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): CylinderDirectedParticleEmitter {\r\n const newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"height\", this.height);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"height\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CYLINDEREMITTER\\n#define DIRECTEDCYLINDEREMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"CylinderDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"CylinderDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\r\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"cylinderParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/cylinderParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAGhC;;;;;;OAMG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,cAAc,CAAC;IACtB;;OAEG;IACI,sBAAsB,CAAC;QAZvB,WAAM,GAAN,MAAM,CAAI;QAIV,WAAM,GAAN,MAAM,CAAI;QAIV,gBAAW,GAAX,WAAW,CAAI;QAIf,wBAAmB,GAAnB,mBAAmB,CAAI;QAzB1B,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IA0BlC,CAAC;IAEJ;;;;;;;OAOG;IACI,sBAAsB,CAAC,WAAmB,EAAE,iBAA0B,EAAE,QAAkB,EAAE,OAAgB,EAAE,kBAA0B;QAC3I,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEhF,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAE7B,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,IAAI,C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,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/E,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cylinder.\r\n * It emits the particles alongside the cylinder radius. The emission direction might be randomized.\r\n */\r\nexport class CylinderParticleEmitter implements IParticleEmitterType {\r\n private _tempVector = Vector3.Zero();\r\n\r\n /**\r\n * Creates a new instance CylinderParticleEmitter\r\n * @param radius the radius of the emission cylinder (1 by default)\r\n * @param height the height of the emission cylinder (1 by default)\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission cylinder.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The height of the emission cylinder.\r\n */\r\n public height = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n * @param inverseWorldMatrix defines the inverted world matrix to use if isLocal is false\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean, inverseWorldMatrix: Matrix): void {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), this._tempVector);\r\n\r\n this._tempVector.normalize();\r\n\r\n Vector3.TransformNormalToRef(this._tempVector, inverseWorldMatrix, this._tempVector);\r\n\r\n const randY = Scalar.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += Scalar.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(this._tempVector);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const yPos = Scalar.RandomRange(-this.height / 2, this.height / 2);\r\n const angle = Scalar.RandomRange(0, 2 * Math.PI);\r\n\r\n // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html\r\n const radiusDistribution = Scalar.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * this.radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(xPos, yPos, zPos);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): CylinderParticleEmitter {\r\n const newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"height\", this.height);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"height\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define CYLINDEREMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"CylinderParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"CylinderParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.height = this.height;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.height = serializationObject.height;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a cylinder.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {\r\n /**\r\n * Creates a new instance CylinderDirectedParticleEmitter\r\n * @param radius the radius of the emission cylinder (1 by default)\r\n * @param height the height of the emission cylinder (1 by default)\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n height = 1,\r\n radiusRange = 1,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, height, radiusRange);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param _particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, _particle: Particle, isLocal: boolean): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): CylinderDirectedParticleEmitter {\r\n const newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"height\", this.height);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"height\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CYLINDEREMITTER\\n#define DIRECTEDCYLINDEREMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"CylinderDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"CylinderDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\r\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\r\n }\r\n}\r\n"]}
|
|
@@ -10,15 +10,15 @@ import type { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class HemisphericParticleEmitter implements IParticleEmitterType {
|
|
12
12
|
/**
|
|
13
|
-
* The radius of the emission hemisphere.
|
|
13
|
+
* [1] The radius of the emission hemisphere.
|
|
14
14
|
*/
|
|
15
15
|
radius: number;
|
|
16
16
|
/**
|
|
17
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
17
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
18
18
|
*/
|
|
19
19
|
radiusRange: number;
|
|
20
20
|
/**
|
|
21
|
-
* How much to randomize the particle direction [0-1].
|
|
21
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
22
22
|
*/
|
|
23
23
|
directionRandomizer: number;
|
|
24
24
|
/**
|
|
@@ -29,15 +29,15 @@ export declare class HemisphericParticleEmitter implements IParticleEmitterType
|
|
|
29
29
|
*/
|
|
30
30
|
constructor(
|
|
31
31
|
/**
|
|
32
|
-
* The radius of the emission hemisphere.
|
|
32
|
+
* [1] The radius of the emission hemisphere.
|
|
33
33
|
*/
|
|
34
34
|
radius?: number,
|
|
35
35
|
/**
|
|
36
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
36
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
37
37
|
*/
|
|
38
38
|
radiusRange?: number,
|
|
39
39
|
/**
|
|
40
|
-
* How much to randomize the particle direction [0-1].
|
|
40
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
41
41
|
*/
|
|
42
42
|
directionRandomizer?: number);
|
|
43
43
|
/**
|
|
@@ -14,15 +14,15 @@ export class HemisphericParticleEmitter {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(
|
|
16
16
|
/**
|
|
17
|
-
* The radius of the emission hemisphere.
|
|
17
|
+
* [1] The radius of the emission hemisphere.
|
|
18
18
|
*/
|
|
19
19
|
radius = 1,
|
|
20
20
|
/**
|
|
21
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
21
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
22
22
|
*/
|
|
23
23
|
radiusRange = 1,
|
|
24
24
|
/**
|
|
25
|
-
* How much to randomize the particle direction [0-1].
|
|
25
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
26
26
|
*/
|
|
27
27
|
directionRandomizer = 0) {
|
|
28
28
|
this.radius = radius;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hemisphericParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/hemisphericParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IACnC;;;;;OAKG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;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AAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACtD,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,GAAkB;QACxC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAQ,EAAE,CAAC;QACpC,mBAAmB,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/C,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzC,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnD,mBAAmB,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QAEnE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAwB;QACjC,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a hemisphere.\r\n * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.\r\n */\r\nexport class HemisphericParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance HemisphericParticleEmitter\r\n * @param radius the radius of the emission hemisphere (1 by default)\r\n * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * The radius of the emission hemisphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange);\r\n const v = Scalar.RandomRange(0, 1.0);\r\n const phi = Scalar.RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, Math.abs(randY), randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): HemisphericParticleEmitter {\r\n const newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define HEMISPHERICEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"HemisphericParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"HemisphericParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"hemisphericParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/hemisphericParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IACnC;;;;;OAKG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,cAAc,CAAC;IACtB;;OAEG;IACI,sBAAsB,CAAC;QARvB,WAAM,GAAN,MAAM,CAAI;QAIV,gBAAW,GAAX,WAAW,CAAI;QAIf,wBAAmB,GAA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AAC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,GAAkB;QACxC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAQ,EAAE,CAAC;QACpC,mBAAmB,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/C,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzC,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnD,mBAAmB,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QAEnE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAwB;QACjC,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a hemisphere.\r\n * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.\r\n */\r\nexport class HemisphericParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance HemisphericParticleEmitter\r\n * @param radius the radius of the emission hemisphere (1 by default)\r\n * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission hemisphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange);\r\n const v = Scalar.RandomRange(0, 1.0);\r\n const phi = Scalar.RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, Math.abs(randY), randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): HemisphericParticleEmitter {\r\n const newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define HEMISPHERICEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"HemisphericParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"HemisphericParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n"]}
|
|
@@ -10,15 +10,15 @@ import type { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class SphereParticleEmitter implements IParticleEmitterType {
|
|
12
12
|
/**
|
|
13
|
-
* The radius of the emission sphere.
|
|
13
|
+
* [1] The radius of the emission sphere.
|
|
14
14
|
*/
|
|
15
15
|
radius: number;
|
|
16
16
|
/**
|
|
17
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
17
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
18
18
|
*/
|
|
19
19
|
radiusRange: number;
|
|
20
20
|
/**
|
|
21
|
-
* How much to randomize the particle direction [0-1].
|
|
21
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
22
22
|
*/
|
|
23
23
|
directionRandomizer: number;
|
|
24
24
|
/**
|
|
@@ -29,15 +29,15 @@ export declare class SphereParticleEmitter implements IParticleEmitterType {
|
|
|
29
29
|
*/
|
|
30
30
|
constructor(
|
|
31
31
|
/**
|
|
32
|
-
* The radius of the emission sphere.
|
|
32
|
+
* [1] The radius of the emission sphere.
|
|
33
33
|
*/
|
|
34
34
|
radius?: number,
|
|
35
35
|
/**
|
|
36
|
-
* The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
36
|
+
* [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.
|
|
37
37
|
*/
|
|
38
38
|
radiusRange?: number,
|
|
39
39
|
/**
|
|
40
|
-
* How much to randomize the particle direction [0-1].
|
|
40
|
+
* [0] How much to randomize the particle direction [0-1].
|
|
41
41
|
*/
|
|
42
42
|
directionRandomizer?: number);
|
|
43
43
|
/**
|