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

three-base

v2.0.111

Published

three 3d three-base

Downloads

227

Readme


.创建一个 homeRender.ts 模块
import { AmbientLight, BoxGeometry, Mesh, MeshLambertMaterial, PointLight } from "three";
import ThreeBase from "three-base";
import Transition from "three-base/Transition";
import Fire from "three-base/Fire";

//qq389652405
class HomeRender extends ThreeBase {

    constructor() {
        super();
    }

    // 环境光
    ambientLight = (() => {
        const ambientLight = new AmbientLight("#fff", 0.4);
        this.scene.add(ambientLight);
        return ambientLight;
    })();

    //点光源
    pointLight = (() => {
        const pointLight = new PointLight("#fff", 0.4);
        pointLight.position.set(50, 40, 50);
        this.scene.add(pointLight);
        return pointLight;
    })();

    init() {
        super.init();
	// 使用这个方法来初始化相机的位置和朝向
        this.resetLookAt({
            center: new Vector3(0, 0, 0),
            position: new Vector3(10.954, 19.452, 39.811)
        });

    }

    //火焰
    fire = (() => {
        const fire = new Fire();
        fire.fireColor = "#ff2200";// 火焰的颜色
        fire.fireScale = 1;// 火焰的整体缩放值
        fire.fireRadius = 0.5;// 火焰的燃烧半径
        fire.fireHeight = 3;// 火焰的高度
        fire.position.set(0, 5, 0);
        this.scene.add(fire);
        return fire;
    })();

    box = (() => {
        const geometry = new BoxGeometry(10, 10, 10);
        const matearil = new MeshLambertMaterial({ color: 0xfff });
        const mesh = new Mesh(geometry, matearil);

	//创建一个动画对象
        const transition = new Transition({ rotationY: 0 });

        // 动画对象播放回调
        transition.onChange(({ rotationY }) => {
            mesh.rotation.y = rotationY;
        });

        mesh.position.set(0, 0, 0);
        mesh.userData = { cursor: "pointer", enableEvent: true };

        // 提供了常用的鼠标事件
        mesh.addEventListener("click", e => { });
        mesh.addEventListener("dbclick", e => { });

        mesh.addEventListener("leftclick", e => {
            transition.set({ rotationY: Math.random() * 5 });
        });
        mesh.addEventListener("rightclick", e => { });
        mesh.addEventListener("mouseenter", e => { });
        mesh.addEventListener("mouseleave", e => { });
        mesh.addEventListener("mousemove", e => { });
        mesh.addEventListener("mousedown", e => { });
        mesh.addEventListener("mouseup", e => { });

        this.scene.add(mesh);
        return mesh;
    })();

}


const homeRenderer = new HomeRender();

// 导出这个单例对象
export default homeRenderer;



2.添加到div里面
import homeRenderer form "./homeRenderer.ts";
homeRenderer.setContainer( document.getElementById("div") );



请尽量使用 vite 来打包

代码: https://gitee.com/drm/vite_react_mobx_threebase