{"version":3,"file":"dev_aiva_2-889d4ea0.js","sources":["../../pages/dev/aiva-2/shaders/box.js","../../pages/dev/aiva-2/script.js"],"sourcesContent":["\nexport const boxVertex = /* glsl */ `\n varying vec2 vUv;\n\n uniform float uTime;\n\n mat4 rotation3d(vec3 axis, float angle) {\n axis = normalize(axis);\n float s = sin(angle);\n float c = cos(angle);\n float oc = 1.0 - c;\n\n return mat4(\n oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,\n oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,\n oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n }\n\n vec3 rotate(vec3 v, vec3 axis, float angle) {\n return (rotation3d(axis, angle) * vec4(v, 1.0)).xyz;\n }\n\n void main() {\n vUv = uv;\n\n vec3 pos = position;\n\n vec3 axis = vec3(1., 0., 0.);\n float twist = 0.1;\n float angle = pos.x * twist;\n\n vec3 transformed = rotate(pos, axis, angle);\n\n // float freq = 0.75;\n // float amp = 1.;\n // transformed.y += cos(transformed.x * freq + 0.) * amp;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.);\n }\n`;\n\nexport const boxFragment = /* glsl */ `\n varying vec2 vUv;\n\n uniform float uTime;\n uniform sampler2D uTexture;\n\n void main() {\n float time = uTime * 0.25;\n float repeat = 3.; // кол-во повторений тектур\n vec2 uv = fract(vUv * repeat - vec2(time, 0.));\n\n // Получаем цвет с текстуры, включая альфа-канал (rgba)\n vec4 textureColor = texture2D(uTexture, uv);\n\n // Используем цвет с альфа-каналом для финального цвета\n gl_FragColor = vec4(textureColor.rgb, textureColor.a);\n }\n`;\n","import * as THREE from 'three'\nimport { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'\nimport GUI from 'lil-gui'\nimport StaticURL from '../../../src/utils/StaticURL.js'\nimport { boxVertex, boxFragment } from './shaders/box.js';\n\n// Debug\nconst debugMode = location.hash === '#debug';\nconst gui = new GUI();\ngui.hide();\nif (debugMode) gui.show();\n\nconst imgURL = new StaticURL('aiva', 'textures', 'd');\n\nTHREE.ColorManagement.enabled = false\n\n/**\n * Base\n */\nconst canvas = document.querySelector('canvas.webgl'); // Canvas\nconst scene = new THREE.Scene(); // Scene\n\n\n// Textures\nconst loadingManager = new THREE.LoadingManager();\n\nloadingManager.onStart = () => {\n console.log('start');\n}\nloadingManager.onProgress = (url, loaded, total) => {\n console.log('progress', url, loaded, total);\n}\nloadingManager.onLoad = () => {\n console.log('load');\n}\nloadingManager.onError = () => {\n console.log('load');\n}\n\n/**\n * Loaders\n */\nconst textureLoader = new THREE.TextureLoader();\n\nconst objectsGroup = new THREE.Group();\nscene.add(objectsGroup);\n\nobjectsGroup.position.x = 3.7\nobjectsGroup.position.z = -.6\nobjectsGroup.rotation.z = -Math.PI / 3.8\n\nconst guiFolderObjectsPosition = gui.addFolder('Objects position');\nguiFolderObjectsPosition.add(objectsGroup.position, 'x').min(-6).max(6).step(.001);\nguiFolderObjectsPosition.add(objectsGroup.position, 'y').min(-6).max(6).step(.001);\nguiFolderObjectsPosition.add(objectsGroup.position, 'z').min(-6).max(6).step(.001);\nconst guiFolderObjectsRotation = gui.addFolder('Objects rotation');\nguiFolderObjectsRotation.add(objectsGroup.rotation, 'x').min(-Math.PI).max(Math.PI).step(.001);\nguiFolderObjectsRotation.add(objectsGroup.rotation, 'y').min(-Math.PI).max(Math.PI).step(.001);\nguiFolderObjectsRotation.add(objectsGroup.rotation, 'z').min(-Math.PI).max(Math.PI).step(.001);\n\nconst shTexture = textureLoader.load(imgURL.get('Animation_bg_1.png'));\nconst shBGTechTexture = textureLoader.load(imgURL.get('Animation_bg_2.png'));\n\nshBGTechTexture.rotation = Math.PI * .25;\n// shBGTechTexture.magFilter = THREE.NearestFilter;\n\n\nconst geometryCentral = new THREE.BoxGeometry(50, 10, 10, 64, 64, 64);\nconst materialCentral = new THREE.ShaderMaterial({\n vertexShader: boxVertex,\n fragmentShader: boxFragment,\n uniforms: {\n uTime: { value: 0 },\n uTexture: { value: shTexture },\n },\n defines: {\n PI: Math.PI\n },\n side: THREE.FrontSide\n});\nmaterialCentral.repe\nconst meshCentral = new THREE.Mesh(geometryCentral, materialCentral)\nmeshCentral.rotation.set(Math.PI, 0, .45);\nmeshCentral.scale.set(0.35, -0.18, -0.18);\nobjectsGroup.add(meshCentral);\n\n\nconst geometry2Central = new THREE.BoxGeometry(50, 10, 10, 64, 64, 64);\nconst material2Central = new THREE.ShaderMaterial({\n vertexShader: boxVertex,\n fragmentShader: boxFragment,\n uniforms: {\n uTime: { value: 0 },\n uTexture: { value: shBGTechTexture },\n },\n defines: {\n PI: Math.PI\n },\n transparent: true,\n side: THREE.FrontSide\n});\nconst mesh2Central = new THREE.Mesh(geometry2Central, material2Central)\nmesh2Central.rotation.set(Math.PI, 0, .45);\nmesh2Central.scale.set(0.351, -0.181, -0.181);\nobjectsGroup.add(mesh2Central);\n\n/**\n * Sizes\n */\nconst sizes = {\n width: window.innerWidth,\n height: window.innerHeight\n}\n\nwindow.addEventListener('resize', () => {\n // Update sizes\n sizes.width = window.innerWidth\n sizes.height = window.innerHeight\n\n // Update camera\n camera.aspect = sizes.width / sizes.height\n camera.updateProjectionMatrix()\n\n // Update renderer\n renderer.setSize(sizes.width, sizes.height)\n renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))\n})\n\n/**\n * Camera\n */\n// Base camera\nconst camera = new THREE.PerspectiveCamera(75, sizes.width / sizes.height, .1, 10)\ncamera.position.z = 4.3\nscene.add(camera)\n\n\nconst guiFolderCamera = gui.addFolder('Camera position');\nguiFolderCamera.add(camera.position, 'x').min(-3).max(15).step(.001);\nguiFolderCamera.add(camera.position, 'y').min(-3).max(15).step(.001);\nguiFolderCamera.add(camera.position, 'z').min(-3).max(15).step(.001);\n\n// Controls\nconst controls = new OrbitControls(camera, canvas)\ncontrols.enableDamping = true\ncontrols.enabled = debugMode\ngui.add(controls, 'enabled').name('OrbitControls')\n\n/**\n * Renderer\n */\nconst renderer = new THREE.WebGLRenderer({\n canvas: canvas,\n alpha: true // прозрачность холста включена\n})\nrenderer.outputColorSpace = THREE.LinearSRGBColorSpace\nrenderer.setSize(sizes.width, sizes.height)\nrenderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))\nrenderer.setClearColor(0x000000, 0); // делаю фон холста прозрачным\n\n/**\n * Animate\n */\nconst clock = new THREE.Clock()\nlet previousElapsedTime = 0;\n\nconst rotationSpeed = 2 * Math.PI / 8; // Скорость вращения: одно полное вращение за 8 секунд\nconst axis = new THREE.Vector3(1, 0, 0); // Локальная ось X\n\nconst tick = () => {\n const elapsedTime = clock.getElapsedTime()\n const deltaTime = elapsedTime - previousElapsedTime;\n previousElapsedTime = elapsedTime;\n\n // Update controls\n controls.update()\n\n // Render\n renderer.render(scene, camera)\n\n materialCentral.uniforms.uTime.value = -elapsedTime * .5;\n material2Central.uniforms.uTime.value = elapsedTime * .2;\n\n // Call tick again on the next frame\n window.requestAnimationFrame(tick)\n\n}\n\ntick()\n"],"names":["boxVertex","boxFragment","debugMode","gui","GUI","imgURL","StaticURL","THREE.ColorManagement","canvas","scene","THREE.Scene","loadingManager","THREE.LoadingManager","url","loaded","total","textureLoader","THREE.TextureLoader","objectsGroup","THREE.Group","guiFolderObjectsPosition","guiFolderObjectsRotation","shTexture","shBGTechTexture","geometryCentral","THREE.BoxGeometry","materialCentral","THREE.ShaderMaterial","THREE.FrontSide","meshCentral","THREE.Mesh","geometry2Central","material2Central","mesh2Central","sizes","camera","renderer","THREE.PerspectiveCamera","guiFolderCamera","controls","OrbitControls","THREE.WebGLRenderer","THREE.LinearSRGBColorSpace","clock","THREE.Clock","THREE.Vector3","tick","elapsedTime"],"mappings":"iUACO,MAAMA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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