import "./style.css"; import * as THREE from "https://cdn.skypack.dev/three@0.136.0";…
- User
import "./style.css";
import * as THREE from "https://cdn.skypack.dev/three@0.136.0"; import { OrbitControls } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/controls/OrbitControls";
var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 ); camera.position.set(0, 0, 14); camera.lookAt(scene.position); var renderer = new THREE.WebGLRenderer({ antialias: true, }); renderer.setClearColor(0x252025); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement);
var controls = new OrbitControls(camera, renderer.domElement);
var geom = new THREE.SphereBufferGeometry(5, 180, 90); // var colors = []; // var color = new THREE.Color(); // var q = ["white"]; // // for (let i = 0; i < geom.attributes.position.count; i++) { // // color.set(q[THREE.Math.randInt(0, q.length - 1)]); // // color.toArray(colors, i * 3); // // } // // geom.setAttribute( // // "color", // // new THREE.BufferAttribute(new Float32Array(colors), 3) // // );
var loader = new THREE.TextureLoader(); loader.setCrossOrigin(""); var texture = loader.load( "https://cywarr.github.io/small-shop/earthspec1k[1].jpg" ); texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set(1, 1); var disk = loader.load( "https://threejs.org/examples/textures/sprites/circle.png" );
var 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;
code - Assistant
To remove the shader rotation effect from your
THREE.jscode, which pertains to the shifting of the texture coordinates in the fragment shader, you can simply remove the portion of the code that modifies theshiftuniform in therenderfunction. The texture displacement in the fragment shader is controlled by theshiftvariable, and if we set that value to a constant (e.g., 0) during rendering, it will effectively stop any movement.Here's how you can modify your existing code:
- Remove the time-based update of the
shiftuniform in the function.
- Remove the time-based update of the
- User
orbit control auto rotate
- Assistant