Git Product home page Git Product logo

threejs-vite-starter's Introduction

threejs-vite-starter's People

Contributors

flanb avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

bhar1gitr

threejs-vite-starter's Issues

✨(sound): Create sound manager script

Like this :

import EventDispatcher from './EventDispatcher';

class SoundManager extends EventDispatcher {
    constructor() {
        super();

        this.$sounds = {
            ambient: new Audio('/sounds/ambient-music.mp3'),
            'ambient-loop': new Audio('/sounds/ambient-loop.mp3'),
        };

        this.$sounds['ambient-loop'].loop = true;

        //son d'intro
        //son d'ambiance
        //swoosh
    }

    /**
     * Getters & Setters
     */

    /**
     * Public
     */
    play(name) {
        return new Promise((resolve) => {
            this.$sounds[name].play();
            this.$sounds[name].addEventListener('ended', resolve);
        });
    }

    playAll() {
        for (let name in this.$sounds) {
            this.$sounds[name].play();
        }
    }

    pause(name) {
        this.$sounds[name].pause();
    }

    pauseAll() {
        for (let name in this.$sounds) {
            this.$sounds[name].pause();
        }
    }

    stop(name) {
        this.$sounds[name].stop();
        this.$sounds[name].currentTime = 0;
    }

    stopAll() {
        for (let name in this.$sounds) {
            this.$sounds[name].pause();
            this.$sounds[name].currentTime = 0;
        }
    }

    muteAll() {
        for (let name in this.$sounds) {
            this.$sounds[name].muted = true;
        }
        this._allMuted = true;
    }

    unmuteAll() {
        for (let name in this.$sounds) {
            this.$sounds[name].muted = false;
        }
        this._allMuted = false;
    }

    toggleMuteAll() {
        if (this._allMuted) {
            this.unmuteAll();
        } else {
            this.muteAll();
        }
    }

    /**
     * Private
     */

    /**
     * Handlers
     */
}

export default new SoundManager();

🐛 (draco): use draco loader

Ressources.js:58 =>

const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath("/draco/");
this.loaders.gltfLoader.setDRACOLoader(dracoLoader);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.