import * as THREE from "three"; import { OrbitControls } from…
- User
import * as THREE from "three"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
//scene const scene = new THREE.Scene();
//camera const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 ); camera.position.set(0, 0, 14); camera.lookAt(scene.position);
//renderer const renderer = new THREE.WebGLRenderer({ antialias: true, }); renderer.setClearColor(0x000000); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement);
//orbti controls const controls = new OrbitControls(camera, renderer.domElement); controls.autoRotate = true; controls.autoRotateSpeed = 2.0;
//create globe
const geom = new THREE.SphereBufferGeometry(5, 180, 90);
//load map texture const loader = new THREE.TextureLoader(); loader.setCrossOrigin(""); const texture = loader.load("/earthspec1k.jpg"); texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set(1, 1);
//particle texture const disk = loader.load("/circle.png");
const points = new THREE.Points( geom, new THREE.ShaderMaterial({ vertexColors: THREE.VertexColors, uniforms: { visibility: { value: texture, }, shift: { value: 0, }, shape: { value: disk, }, size: { value: 0.2, }, scale: { value: window.innerHeight / 2, }, }, vertexShader: ` uniform float scale; uniform float size; varying vec2 vUv; varying vec3 vColor;
codevoid main() { vUv = uv; vColor = color; vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_PointSize = size * ( scale / length( mvPosition.xyz )) * (0.3 + sin(uv.y * 3.1415926) * 0.6 ); gl_Position = projectionMatrix * mvPosition; } `, fragmentShader: ` uniform sampler2D visibility; uniform float shift; uniform sampler2D shape; varying vec2 vUv; varying vec3 vColor; void main() { vec2 uv = vUv; uv.x += shift; vec4 v = texture2D(visibility, uv); if (length(v.rgb) > 1.0) discard; gl_FragColor = vec4(vColor, 1.0); vec4 shapeData = texture2D(shape, gl_PointCoord); if (shapeData.a < 0.0625) discard; gl_FragColor = gl_FragColor * shapeData; } `, transparent: false, - Assistant
- User
give complete code for just copy and paste
- Assistant
- User
onHover sphere orbit control stop this part is miss
- Assistant