function buildScene() { const scene = new THREE.Scene(); scene.background = new THREE.Color("#FFF"); return scene; }
function Sky(scene, world, opts) { this.time = opts.time || 0 this.speed = opts.speed || 0.05 this.color = opts.color || new THREE.Color(0, 0, 0) this.prevTime = performance.now() this.getWorld = () => world this.getWorldSize = () => (world.data.user.settings.renderDistance - 1) * SIZE * DIMENSION * 2 this.getScene = () => scene }
function StarsBackground() { let group = useRef() let theta = 0 useFrame(() => { // Some things maybe shouldn't be declarative, we're in the render-loop here with full access to the instance const r = 5 * Math.sin(THREE.Math.degToRad((theta += 0.1))) const s = Math.cos(THREE.Math.degToRad(theta * 2)) group.current.rotation.set(r, r, r) group.current.scale.set(s, s, s) }) const [geo, mat, vertices, coords] = useMemo(() => { const geo = new THREE.SphereBufferGeometry(1, 10, 10) const mat = new THREE.MeshBasicMaterial({ color: new THREE.Color('lightblue') }) const coords = new Array(2000).fill().map(i => [Math.random() * 800 - 400, Math.random() * 800 - 400, Math.random() * 800 - 400]) return [geo, mat, vertices, coords] }, []) return ( <group ref={group}> {coords.map(([p1, p2, p3], i) => ( <mesh key={i} geometry={geo} material={mat} position={[p1, p2, p3]} /> ))} </group> ) }
_createPointNodes(d, tileContent) { const geometry = new THREE.BufferGeometry(); geometry.addAttribute('position', new THREE.Float32BufferAttribute(d.points, 3)); const material = new THREE.PointsMaterial(); material.size = this.styleParams.pointsize !== null ? this.styleParams.pointsize : 1.0; if (this.styleParams.color) { material.vertexColors = THREE.NoColors; material.color = new THREE.Color(this.styleParams.color); material.opacity = this.styleParams.opacity !== null ? this.styleParams.opacity : 1.0; } else if (d.rgba) { geometry.addAttribute('color', new THREE.Float32BufferAttribute(d.rgba, 4)); material.vertexColors = THREE.VertexColors; } else if (d.rgb) { geometry.addAttribute('color', new THREE.Float32BufferAttribute(d.rgb, 3)); material.vertexColors = THREE.VertexColors; } tileContent.add(new THREE.Points(geometry, material)); if (d.rtc_center) { const c = d.rtc_center; tileContent.applyMatrix(new THREE.Matrix4().makeTranslation(c[0], c[1], c[2])); } tileContent.add(new THREE.Points(geometry, material)); return tileContent; }
color = color || new THREE.Color(0xf8ffb5)
gltf => { if (this.styleParams.color !== null || this.styleParams.opacity !== null) { const color = new THREE.Color(this.styleParams.color); gltf.scene.traverse(child => { if (child instanceof THREE.Mesh) {
position: [x * 0.2, length * 2, z * 0.2], size: [0.2, 1, 0.2], color: new THREE.Color( `hsl(${normalizeHsl(Math.abs(length))}, 100%, 60%)`, ),
this.scene.background = new THREE.Color(BACKGROUND_CONFIG.color) this.scene.fog = new THREE.Fog( FOG_CONFIG.color,
position: [x * 0.2, 1, z * 0.2], size: [0.2, 1, 0.2], color: new THREE.Color(`hsl(${100}, 100%, 60%)`), });
export default function(phase, r, color) { if (!this.canvas) return false r = r || 20 color = color || new THREE.Color(0xe6e2d1) const x = this.canvas.width / 2 const y = this.canvas.height / 2
function Stars() { let group = useRef() let theta = 0 useRender(() => { // Some things maybe shouldn't be declarative, we're in the render-loop here with full access to the instance const r = 5 * Math.sin(THREE.Math.degToRad((theta += 0.1))) const s = Math.cos(THREE.Math.degToRad(theta * 2)) group.current.rotation.set(r, r, r) group.current.scale.set(s, s, s) }) const [geo, mat, vertices, coords] = useMemo(() => { const geo = new THREE.SphereBufferGeometry(1, 10, 10) const mat = new THREE.MeshBasicMaterial({ color: new THREE.Color('lightblue') }) const coords = new Array(2000).fill().map(i => [Math.random() * 800 - 400, Math.random() * 800 - 400, Math.random() * 800 - 400]) return [geo, mat, vertices, coords] }, []) return ( <group ref={group}> {coords.map(([p1, p2, p3], i) => ( <mesh key={i} geometry={geo} material={mat} position={[p1, p2, p3]} /> ))} </group> ) }
position: [x * 0.2, length * 2, z * 0.2], size: [0.2, 1, 0.2], color: new THREE.Color( `hsl(${normalizeHsl(Math.abs(length))}, 100%, 60%)`, ),