source . ':' . ($this->slug ?: (string) $this->sourceId); } public function display_id(): string { return strtoupper(trim($this->slug ?: (string) $this->sourceId)); } public function label(): string { $id = $this->display_id(); $name = trim($this->name); return '' !== $name && 0 !== strcasecmp($id, $name) ? $id . ' - ' . $name : $id; } public function colors(): array { return array_values(array_unique(array_filter(array_merge([$this->baseColor], $this->secondaryColors)))); } public function jsonSerialize(): array { return [ 'source' => $this->source, 'source_id' => $this->sourceId, 'identifier' => $this->identifier(), 'slug' => $this->slug, 'display_id' => $this->display_id(), 'name' => $this->name, 'label' => $this->label(), 'material_type' => $this->materialType, 'appearance_type' => $this->appearanceType, 'color_mode' => $this->colorMode, 'color_mode_type' => $this->colorModeType, 'color_direction' => (string) ($this->sourceData['color_direction'] ?? (($this->colorModeType === 'rainbow') ? 'bottom_top' : 'left_right')), 'color_blend_percent' => (float) ($this->sourceData['color_blend_percent'] ?? 45), 'color_shares' => array_values((array) ($this->sourceData['color_shares'] ?? [25,25,25,25])), 'layer_band_percent' => (float) ($this->sourceData['layer_band_percent'] ?? 1), 'layer_variation_percent' => (float) ($this->sourceData['layer_variation_percent'] ?? 10), 'layer_blend_percent' => (float) ($this->sourceData['layer_blend_percent'] ?? 6), 'manufacturer' => $this->manufacturer, 'base_color' => $this->baseColor, 'secondary_colors' => $this->secondaryColors, 'background_color' => $this->backgroundColor, 'texture_url' => $this->textureUrl, 'normal_map_url' => $this->normalMapUrl, 'roughness' => $this->roughness, 'metalness' => $this->metalness, 'opacity' => $this->opacity, 'transparent' => $this->transparent, 'preview_image_url' => $this->previewImageUrl, 'preview_video_url' => $this->previewVideoUrl, 'advanced_enabled' => !empty($this->sourceData['advanced_enabled']), 'clearcoat' => (float) ($this->sourceData['clearcoat'] ?? 0), 'sheen' => (float) ($this->sourceData['sheen'] ?? 0), 'iridescence' => (float) ($this->sourceData['iridescence'] ?? 0), 'transmission' => (float) ($this->sourceData['transmission'] ?? 0), 'ior' => (float) ($this->sourceData['ior'] ?? 1.5), 'light_key' => (float) ($this->sourceData['light_key'] ?? 1.55), 'light_fill' => (float) ($this->sourceData['light_fill'] ?? 0.55), 'light_ambient' => (float) ($this->sourceData['light_ambient'] ?? 0.85), 'exposure' => (float) ($this->sourceData['exposure'] ?? 1), ]; } }