|
|
@@ -0,0 +1,98 @@ |
|
|
|
import * as THREE from 'three'; |
|
|
|
import {FlakesTexture} from 'three'; |
|
|
|
import textureimg from "/Users/chop/Desktop/chamran/Three/texture/text.png"; |
|
|
|
const OrbitControls = require('three-orbitcontrols') |
|
|
|
|
|
|
|
import DragControls from 'three-dragcontrols'; |
|
|
|
|
|
|
|
const main = document.querySelector("#main"); |
|
|
|
|
|
|
|
|
|
|
|
const scene = new THREE.Scene(); |
|
|
|
const camera = new THREE.PerspectiveCamera(75, innerHeight / innerHeight, 0.1, 1000); |
|
|
|
|
|
|
|
// controls.enableDamping = true |
|
|
|
// controls.dampingFactor = 0.25 |
|
|
|
// controls.enableZoom = false |
|
|
|
|
|
|
|
const light = new THREE.PointLight( 0xffffff, 1, 1000 ); |
|
|
|
light.position.set( 200, 200, 200 ); |
|
|
|
scene.add( light ); |
|
|
|
scene.background = new THREE.Color("#17191c") |
|
|
|
camera.position.set(0, 0, 100); |
|
|
|
const renderer = new THREE.WebGLRenderer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const texture = new THREE.TextureLoader().load( textureimg ); |
|
|
|
texture.wrapS = THREE.RepeatWrapping; |
|
|
|
texture.wrapT = THREE.RepeatWrapping; |
|
|
|
texture.repeat.set( 10, 6 ); |
|
|
|
|
|
|
|
const ballMaterial1 = { |
|
|
|
clearcoat:1.0, |
|
|
|
cleacoatRoughness:0.1, |
|
|
|
metalness:0.9, |
|
|
|
roughness:0.5, |
|
|
|
color:"#8afff1", |
|
|
|
normalMap:texture, |
|
|
|
normalScale: new THREE.Vector2(0.15,0.15) |
|
|
|
} |
|
|
|
|
|
|
|
const ballMaterial2 = { |
|
|
|
clearcoat:1.0, |
|
|
|
cleacoatRoughness:0.1, |
|
|
|
metalness:0.9, |
|
|
|
roughness:0.5, |
|
|
|
color:"red", |
|
|
|
normalMap:texture, |
|
|
|
normalScale: new THREE.Vector2(0.15,0.15) |
|
|
|
} |
|
|
|
|
|
|
|
const dayere = new THREE.SphereGeometry(20,64,64) |
|
|
|
const dayereTex1 = new THREE.MeshPhysicalMaterial(ballMaterial1) |
|
|
|
const dayereTex2 = new THREE.MeshPhysicalMaterial(ballMaterial2) |
|
|
|
const meterial = new THREE.MeshBasicMaterial(); |
|
|
|
meterial.color.set('#e61cc7'); |
|
|
|
const mesh1 = new THREE.Mesh(dayere, dayereTex1) |
|
|
|
const mesh2 = new THREE.Mesh(dayere, dayereTex2) |
|
|
|
mesh1.position.x = 30; |
|
|
|
mesh2.position.x = -30; |
|
|
|
|
|
|
|
|
|
|
|
// var fgeometry = new THREE.PlaneGeometry( 500, 500, 1, 1 ); |
|
|
|
// var fmaterial = new THREE.MeshBasicMaterial( { color: "#1c3ae6" } ) |
|
|
|
// var floor = new THREE.Mesh( fgeometry, fmaterial ); |
|
|
|
// floor.material.side = THREE.DoubleSide; |
|
|
|
// floor.rotation.x = 90; |
|
|
|
// scene.add( floor ); |
|
|
|
|
|
|
|
|
|
|
|
renderer.setSize(innerWidth, innerHeight) |
|
|
|
main.appendChild(renderer.domElement); |
|
|
|
|
|
|
|
|
|
|
|
scene.add(mesh1); |
|
|
|
scene.add(mesh2); |
|
|
|
|
|
|
|
// const controls = new DragControls(geometry, camera, renderer.domElement) |
|
|
|
// console.log(controls); |
|
|
|
// controls.addEventListener('dragstart', function (event) { |
|
|
|
// console.log("adadwdsd"); |
|
|
|
// event.geometry.material.opacity = 0.33 |
|
|
|
// console.log(event); |
|
|
|
// }) |
|
|
|
// controls.addEventListener('dragend', function (event) { |
|
|
|
// event.geometry.material.opacity = 1 |
|
|
|
// }) |
|
|
|
const controlsCamra = new OrbitControls(camera, renderer.domElement) |
|
|
|
|
|
|
|
function animate() { |
|
|
|
controlsCamra.update(); |
|
|
|
requestAnimationFrame(animate); |
|
|
|
renderer.render(scene, camera); |
|
|
|
// mesh.rotation.y += 0.01; |
|
|
|
} |
|
|
|
animate(); |
|
|
|
|