# frozen_string_literal: true # TODO: params shouldn't be merge but they must respect the order # TODO: Add default value for each methods below # TODO: Factorise codes below # TODO we must clarified/unified the usage of presets and sanitizer it is not clear # additional Atome methods class Atome def atome_common(atome_preset, params) basic_params = { renderers: [] } # TODO : remove Essentials.default_params[atome_preset] || {} as it is # applied twice because preset is now a particle preset_params = Essentials.default_params[atome_preset] || {} # preset_params = {preset: atome_preset} basic_params[:type] = preset_params[:type] || :element # basic_params[:aid] = identity_generator(:a) # alert "common => #{params[:id]}" # alert "basic_params #{basic_params[:id].class}" basic_params[:id] = params[:id] || identity_generator basic_params[:renderers] = @renderers || preset_params[:renderers] essential_params = basic_params.merge(preset_params) # reordered_params = essential_params.reject { |key, _| params.has_key?(key) } params = reordered_params.merge(params) params[:id] = params[:id].to_sym # condition to handle color/shadow/paint atomes that shouldn't be attach to view if Universe.applicable_atomes.include?(atome_preset) unless params[:affect] params[:affect] = if @id == :view [:black_matter] else [@id] end end else params[:attach] = params[:attach] || @id || :view end # we reorder the hash reorder_particles(params) end def preset_common(params, &bloc) Atome.new(params, &bloc) end # def box(params = {}, &bloc) # atome_preset = :box # params = atome_common(atome_preset, params) # preset_common(params, &bloc) # end # # # def intuition(params = {}, &bloc) # # atome_preset = :intuition # # params = atome_common(atome_preset, params) # # preset_common(params, &bloc) # # end # # def circle(params = {}, &bloc) # atome_preset = :circle # params = atome_common(atome_preset, params) # preset_common(params, &bloc) # end end