modal #80
|
@ -2,6 +2,8 @@
|
|||
import { getColorNameFromRal } from '@/components/ral'
|
||||
import type { ralTypes } from '@/components/ral'
|
||||
import { apiFetch } from '~/utils/apiFetch';
|
||||
import { getName as getPatternName } from './pattern';
|
||||
import { getName as getTopperName } from './topper';
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const apiBase = config.public.apiBase
|
||||
|
@ -17,6 +19,8 @@ const section_count = useState('section_count')
|
|||
const extra_section = useState('extra_section')
|
||||
const total_length = useState('total_length')
|
||||
const remove_pillar = useState<boolean>('remove_pillar')
|
||||
const pillar_topper = use_topper()
|
||||
const pillar_pattern = use_pattern()
|
||||
|
||||
const toggleModal = () => {
|
||||
modal_data.email = undefined
|
||||
|
@ -164,8 +168,28 @@ const total_txt = computed(() => {
|
|||
value: prices.lam_quad_regular * sections
|
||||
},
|
||||
};
|
||||
const decor = {} as { [key: string]: { txt: string, value?: string } }
|
||||
if (
|
||||
!remove_pillar.value
|
||||
&& (
|
||||
pillar_pattern.value !== 0
|
||||
|| pillar_topper.value !== 0
|
||||
)
|
||||
) {
|
||||
const els = [];
|
||||
const isPattern = pillar_pattern.value !== 0;
|
||||
const isTopper = pillar_topper.value !== 0;
|
||||
if (isPattern) els.push('нанесения узоров на опорные столбы')
|
||||
if (isTopper) els.push('индивидуальный дизайн колпаков')
|
||||
const txt = `Стоимость ${els.join(' и ')} рассчитывается отдельно.`
|
||||
decor.el = {
|
||||
txt: txt,
|
||||
}
|
||||
if (isPattern) decor.pattern = { txt: 'Узор опорного столба', value: getPatternName(pillar_pattern.value) }
|
||||
if (isTopper) decor.topper = { txt: 'Колпак', value: getTopperName(pillar_topper.value) }
|
||||
}
|
||||
|
||||
const total = [extra, regular].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)
|
||||
const total = [extra, regular, decor].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)
|
||||
|
||||
const res_regular = Object.values(regular).map(item =>
|
||||
Object.entries(item).map(el => el[0] == 'value' ? roubleSign.format(el[1] as number) : el[1]).join(': ')
|
||||
|
@ -173,11 +197,15 @@ const total_txt = computed(() => {
|
|||
const res_extra = extra_section.value ? Object.values(extra).map(item =>
|
||||
Object.entries(item).map(el => el[0] == 'value' ? roubleSign.format(el[1] as number) : el[1]).join(': ')
|
||||
).filter(Boolean) : []
|
||||
const res_decor = Object.values(decor).map(item =>
|
||||
Object.entries(item).map(el => el[1]).join(': ')
|
||||
).filter(Boolean)
|
||||
|
||||
const res_total = [`Итого ${roubleSign.format(total)}`]
|
||||
return {
|
||||
regular: res_regular,
|
||||
extra: res_extra,
|
||||
decor: res_decor,
|
||||
total: res_total
|
||||
}
|
||||
})
|
||||
|
|
|
@ -5,7 +5,7 @@ const { controls, camera } = useTresContext();
|
|||
const goto_camera = use_goto_camera();
|
||||
const goto_target = use_goto_target();
|
||||
|
||||
const COUNT = 30
|
||||
const COUNT = 60
|
||||
type smooth = {
|
||||
value: Vector3 | undefined,
|
||||
count: number
|
||||
|
@ -38,7 +38,8 @@ onBeforeLoop(() => {
|
|||
if (smooth_target.count == 1) {
|
||||
set_moveto(smooth_target, undefined);
|
||||
}
|
||||
} else if (smooth_move.value) {
|
||||
}
|
||||
if (smooth_move.value) {
|
||||
camera.value?.position.lerp(smooth_move.value as Vector3, koef);
|
||||
camera.value?.updateMatrixWorld();
|
||||
(controls.value as any).update();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
vec3 scale;
|
||||
scale.x = length(modelMatrix[0].xyz);
|
||||
scale.y = length(modelMatrix[1].xyz);
|
||||
scale.z = length(modelMatrix[2].xyz);
|
||||
|
||||
// Применяем масштаб к позиции вершины
|
||||
vPosition = (position.xyz + normal) * scale;
|
|
@ -1,51 +0,0 @@
|
|||
float random(in float x) {
|
||||
return fract(sin(x) * 1e4);
|
||||
}
|
||||
|
||||
// Based on Morgan McGuire @morgan3d
|
||||
// https://www.shadertoy.com/view/4dS3Wd
|
||||
float noise(in vec3 p) {
|
||||
const vec3 step = vec3(110.0, 241.0, 171.0);
|
||||
|
||||
vec3 i = floor(p);
|
||||
vec3 f = fract(p);
|
||||
|
||||
// For performance, compute the base input to a
|
||||
// 1D random from the integer part of the
|
||||
// argument and the incremental change to the
|
||||
// 1D based on the 3D -> 1D wrapping
|
||||
float n = dot(i, step);
|
||||
|
||||
vec3 u = f * f * (3.0 - 2.0 * f);
|
||||
return mix(mix(mix(random(n + dot(step, vec3(0, 0, 0))), random(n + dot(step, vec3(1, 0, 0))), u.x), mix(random(n + dot(step, vec3(0, 1, 0))), random(n + dot(step, vec3(1, 1, 0))), u.x), u.y), mix(mix(random(n + dot(step, vec3(0, 0, 1))), random(n + dot(step, vec3(1, 0, 1))), u.x), mix(random(n + dot(step, vec3(0, 1, 1))), random(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
|
||||
}
|
||||
|
||||
// <https://www.shadertoy.com/view/Xd23Dh>
|
||||
// by inigo quilez <http://iquilezles.org/www/articles/voronoise/voronoise.htm>
|
||||
//
|
||||
|
||||
vec3 hash3(vec2 p) {
|
||||
vec3 q = vec3(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)), dot(p, vec2(419.2, 371.9)));
|
||||
return fract(sin(q) * 43758.5453);
|
||||
}
|
||||
|
||||
float iqnoise(in vec2 x, float u, float v) {
|
||||
vec2 p = floor(x);
|
||||
vec2 f = fract(x);
|
||||
|
||||
float k = 1.0 + 63.0 * pow(1.0 - v, 4.0);
|
||||
|
||||
float va = 0.0;
|
||||
float wt = 0.0;
|
||||
for(int j = -2; j <= 2; j++) for(int i = -2; i <= 2; i++) {
|
||||
vec2 g = vec2(float(i), float(j));
|
||||
vec3 o = hash3(p + g) * vec3(u, u, 1.0);
|
||||
vec2 r = g - f + o.xy;
|
||||
float d = dot(r, r);
|
||||
float ww = pow(1.0 - smoothstep(0.0, 1.414, sqrt(d)), k);
|
||||
va += o.z * ww;
|
||||
wt += ww;
|
||||
}
|
||||
|
||||
return va / wt;
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
import {
|
||||
Color, DataTexture, DoubleSide,
|
||||
Color, DoubleSide,
|
||||
MeshStandardMaterial, RepeatWrapping,
|
||||
Texture, TextureLoader, Vector3
|
||||
Texture, TextureLoader,
|
||||
type WebGLProgramParameters
|
||||
} from "three"
|
||||
import { useLoader, } from '@tresjs/core'
|
||||
import vertexShader from './vertex.vert?raw'
|
||||
import mainShader from './main.frag?raw'
|
||||
import normalShader from './normal.frag?raw'
|
||||
import dithShader from './dith.frag?raw'
|
||||
import noiseShader from './pnoise.glsl?raw'
|
||||
import { getFilename, patterns, } from "~/components/pattern"
|
||||
import { getFilename, patterns, type patternIds, } from "~/components/pattern"
|
||||
|
||||
import vertexShader from '../shaders/noise/vertex.vert?raw'
|
||||
import normalShader from '../shaders/noise/normal.frag?raw'
|
||||
import dithShader from '../shaders/noise/dith.frag?raw'
|
||||
import noiseShader from '../shaders/noise/pnoise.glsl?raw'
|
||||
|
||||
const set_metaril_func = (scene: any, material: any) => {
|
||||
scene.children.forEach((el: any) => {
|
||||
|
@ -28,60 +28,25 @@ for (let index = 0; index < patterns.length; index++) {
|
|||
const element = patterns[index];
|
||||
const filename = getFilename(element.id)
|
||||
if (filename) {
|
||||
// @ts-ignore
|
||||
loaded_patterns[filename] = useLoader(TextureLoader, filename)
|
||||
}
|
||||
}
|
||||
Promise.all(Object.keys(loaded_patterns))
|
||||
|
||||
function generateNoiseTexture(width: number, height: number) {
|
||||
const size = width * height;
|
||||
const data = new Uint8Array(4 * size);
|
||||
|
||||
for (let i = 0; i < size; i++) {
|
||||
const r = Math.floor(Math.random() * 255) * 0.05;
|
||||
const g = 0;
|
||||
const b = Math.floor(Math.random() * 255) * 0.05;
|
||||
|
||||
const stride = i * 4;
|
||||
data[stride] = r;
|
||||
data[stride + 1] = g;
|
||||
data[stride + 2] = b;
|
||||
data[stride + 3] = 255;
|
||||
}
|
||||
|
||||
// used the buffer to create a DataTexture
|
||||
const texture = new DataTexture(data, width, height);
|
||||
texture.needsUpdate = true;
|
||||
return texture;
|
||||
}
|
||||
|
||||
const m = new MeshStandardMaterial({
|
||||
const noiseMaterial = new MeshStandardMaterial({
|
||||
// alphaMap: pattern ? texture : null,
|
||||
transparent: true,
|
||||
opacity: 1,
|
||||
roughness: 0.5,
|
||||
roughness: 0.2,
|
||||
metalness: 0,
|
||||
side: DoubleSide,
|
||||
})
|
||||
|
||||
const v = new Vector3()
|
||||
v.setScalar(0.7)
|
||||
const m_onBeforeCompile = (shader) => {
|
||||
// Добавляем uniform переменную
|
||||
shader.uniforms.u_resolution = { value: v };
|
||||
|
||||
const m_onBeforeCompile = (shader: WebGLProgramParameters) => {
|
||||
// Изменяем вершинный шейдер
|
||||
shader.vertexShader = `
|
||||
uniform vec3 u_resolution;
|
||||
|
||||
varying float vDistance;
|
||||
varying vec3 vPosition;
|
||||
|
||||
flat varying int vertexID;
|
||||
|
||||
varying vec2 vUv;
|
||||
varying float noise;
|
||||
|
||||
${shader.vertexShader}
|
||||
`.replace(
|
||||
`#include <begin_vertex>`,
|
||||
|
@ -92,14 +57,9 @@ const m_onBeforeCompile = (shader) => {
|
|||
|
||||
// Изменяем фрагментный шейдер
|
||||
shader.fragmentShader = `
|
||||
uniform vec3 u_resolution;
|
||||
|
||||
varying float vDistance;
|
||||
varying vec3 vPosition;
|
||||
int vertexID;
|
||||
|
||||
${noiseShader}
|
||||
${mainShader}
|
||||
${shader.fragmentShader}`
|
||||
.replace(
|
||||
'#include <normal_fragment_begin>',
|
||||
|
@ -115,10 +75,10 @@ const m_onBeforeCompile = (shader) => {
|
|||
`
|
||||
);
|
||||
};
|
||||
export const set_material = (scene: any, color: any, pattern: { pattern: patternTypes, count: number } | undefined = undefined) => {
|
||||
export const set_material = (scene: any, color: any, pattern: { pattern: patternIds, count: number } | undefined = undefined) => {
|
||||
let c = color
|
||||
|
||||
const material = m.clone()
|
||||
const material = noiseMaterial.clone()
|
||||
material.color = new Color(c || '#9c9c00')
|
||||
material.onBeforeCompile = m_onBeforeCompile
|
||||
|
||||
|
|
2416
utils/shaderData.ts
2416
utils/shaderData.ts
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +0,0 @@
|
|||
vertexID = gl_VertexID;
|
||||
vUv = uv;
|
||||
|
||||
float distanceToNextVertex = length(u_resolution - vec3(0.0, 0.0, 0.0));
|
||||
vDistance = distanceToNextVertex;
|
||||
|
||||
vPosition = position.xyz + normal;
|
||||
vec3 scale;
|
||||
scale.x = length(modelMatrix[0].xyz);
|
||||
scale.y = length(modelMatrix[1].xyz);
|
||||
scale.z = length(modelMatrix[2].xyz);
|
||||
|
||||
// Применяем масштаб к позиции вершины
|
||||
vPosition = position * scale;
|
Loading…
Reference in New Issue