UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

38 lines (37 loc) 1.4 kB
"use strict"; import { BaseSopOperation } from "./_Base"; import { Vector2 } from "three"; import { InputCloneMode } from "../../../engine/poly/InputCloneMode"; import { CoreMask } from "../../../core/geometry/Mask"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { textureSizeFromPointsCount } from "../../../core/geometry/operation/TextureFromAttribute"; import { coreParticlesInitParticlesUVs } from "../../../core/particles/CoreParticlesInit"; const _textureSize = new Vector2(); export class ParticlesSystemGpuAttributesSopOperation extends BaseSopOperation { static type() { return SopType.PARTICLES_SYSTEM_GPU_ATTRIBUTES; } cook(inputCoreGroups, params) { const coreGroup = inputCoreGroups[0]; const selectedObjects = CoreMask.filterThreejsObjects(coreGroup, params); for (let selectedObject of selectedObjects) { this._applyAttributes(selectedObject, params); } return coreGroup; } _applyAttributes(object, params) { if (object.isGroup) { return; } const geometry = object.geometry; if (!geometry) { return; } textureSizeFromPointsCount(geometry, _textureSize); coreParticlesInitParticlesUVs(object, _textureSize); } } ParticlesSystemGpuAttributesSopOperation.DEFAULT_PARAMS = { group: "" }; ParticlesSystemGpuAttributesSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;