npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sthree-js

v0.0.51

Published

![logo](sthree.jpg) # STHREE A Three.js component library project inspired by the svelte-cubed project, and other wonderful tools like React Three Fiber and react-three/drei

Downloads

2

Readme

logo

STHREE

A Three.js component library project inspired by the svelte-cubed project, and other wonderful tools like React Three Fiber and react-three/drei

Getting Started

npm install sthree-js

Usage

import * as St from 'sthree-js';

Index Basic Features

Index Advanced Features

Index Basic Features

Cameras

PerspectiveCamera

A standard THREE.PerspectiveCamera

<St.PerspectiveCamera/>

CubeCamera

A standard THREE.CubeCamera

export let envMap
$: chromeMaterial = new THREE.MeshLambertMaterial( { color: 0x555fff, envMap: envMap } );
<St.CubeCamera bind:envMap/>

Controls

OrbitControls

A standard OrbitControls

<St.OrbitControls/>

Light

DirectionalLight

A standard THREE.DirectionalLight

<St.DirectionalLight/>

Loader

useGLTF

useGLTF an easy way to async load 3d models in gltf format

import {useGltf} from 'sthree-js';
onMount(async() => {
	 gltf = await useGltf ('/models/gltf/Fox.glb');
	 model = gltf.scene; 	
	 <St.Primitive object={model} scale ={1} on:mouseover ={play} isInterative={true} />
});

Objects.

Group

A standard THREE.Group

<St.Group bind:group={group1}  position = {[0,0,0]} id={'view4'} >
        <St.Sprite id= {'view4'} isInterative = {true} on:click={exemplo} position = {[0,0,5]} group= {group1} />
        <St.Mesh isInterative = {true} on:click={exemplo} group={group1} id= {'view4'} geometry = {myBox}  position = {[1,1,0]} scale ={3}  material ={chromeMaterial}/>
        <St.Mesh isInterative = {true} on:click={exemplo} group={group1} id= {'view4'} geometry = {myBox}  position = {[-1,-1,0]} scale ={1} material ={chromeMaterial}/>
        <St.DirectionalLight id={'view4'} />
</St.Group>

Mesh

A standard THREE.Mesh

let Sphere = new THREE.SphereGeometry();
<St.Mesh geometry = {Sphere}  scale ={1} isInterative = {true} material ={material} />

Primitive

an easy way to place objects, cameras, light, etc.

<St.Primitive object={model} scale ={1} on:mouseover ={play} isInterative={true} />
Sprite

Sprite

sprite is a plane that always faces towards the camera

<St.Sprite isInterative = {true} on:click={exemplo} position = {[1,0,-30]}/>

Raycaster

Raycaster

A standard THREE.Raycaster to activate the raycaster sister, simply activate it on the objects: isInterative = {true} and on:eventname

<St.Primitive object={model} scale ={.3} on:mouseover ={play} isInterative={true} />

Index Advanced Features

Controls

ScrollControls

ScrollControls allow you to make scroll effects. it works with a container in front of the threejs screen. everything inside < ScrollControls > will be affected, including HTML components.

 <St.Canvas>	
        <St.ScrollControls> 
            <div>
                <button class="class" on:click={()=> press()} > button </button>
            </div>
            <St.PerspectiveCamera/>
            <St.Mesh geometry = {myBox}  scale ={.5} isInterative = {true} material ={chromeMaterial}/>
            <St.DirectionalLight/>
        </St.ScrollControls>
    </St.Canvas>	
    

it is possible to access scroll data through the ScrollProps store, the current scroll, and range functions: range, curve and visible

 import { ScrollProps } from 'sthree-js';
 $: if ($ScrollProps) {
        r1 = $ScrollProps.range(0/4, 1/4);
 }

Enviroment

Enviroment

Enviroment allows you to easily include an environment map or an equirectangular Texture such as a CubeTexture in the 3d scene, in addition to providing an integrated access to a CubeCamera that returns a texture already mapped from the current camera to be applied to your materials

<St.Environment files={'royal_esplanade_1k.hdr'} path ={'textures/equirectangular/'} bind:envMap />

for convenience is available by default: a selection of HDRI Haven presets.

<St.Environment preset={sunset} />

The option to activate a GroundProjectedEnv is also available

<St.Environment ground={true} />

Portal

View

Used to cut the viewport into segments, each segment has its own div, allowing you to have multiple views with a single screen. This resource uses the setScissor method to cut the screen into multiple views.

<St.Canvas frameloop = {'always'}>
  <St.View isInterative = {true} id={'view1'} top ={'0%'} left ={'0%'} position={'relative'} > 
    <St.Mesh isInterative = {true} on:click={exemplo} group={group} id= {'view1'} geometry = {myBox}  position = {[1,1,0]} scale ={3}  material ={chromeMaterial}/>
    <St.Mesh isInterative = {true} on:click={exemplo} group={group} id= {'view1'} geometry = {myBox}  position = {[-1,-1,0]} scale ={1} material ={chromeMaterial}/>
  </St.View> 
    
  <St.View isInterative = {true} id={'view2'} top ={'50%'} left ={'0%'} position={'relative'} > 
    <St.PerspectiveCamera id= {'view2'}/>   
      <St.Mesh isInterative = {true} on:click={exemplo} group={group} id= {'view2'} geometry = {myBox}  position = {[1,1,0]} scale ={3}  material ={chromeMaterial}/>
  </St.View> 
 </St.Canvas>

Post-Processing

EffectComposer

Using a sequence of passes applies the post-processing effect They are executed in the order they were added in the pass matrix. The last pass is an automatic process that renders the screen.

first add all your passes in an array:

import { GammaCorrectionShader } from 'three/examples/jsm/shaders/GammaCorrectionShader.js';
let pass : Pass [] = []; 
pass[0]= new ShaderPass( GammaCorrectionShader );

transfer this array to EffectComposer:

<St.EffectComposer addPass={pass} >
  <St.Mesh isInterative = {true} on:click={exemplo} group={group} geometry = {myBox}  position = {[-1,-1,0]} scale ={1} material ={chromeMaterial}/>
  <St.DirectionalLight  />
  <St.OrbitControls/>
</St.EffectComposer> 

development

This is a study project and still under development can expect errors