Coder Social home page Coder Social logo

t3d-pano's Introduction

t3d-pano

NPM Package

Panorama extension for t3d.

Demo

Getting Started

Create pano:

const pano = new Pano();
scene.add(pano);

pano.visible = true;
pano.material.diffuseMap = texture;
pano.material.opacity = 1;
pano.material.uniforms.stretchFactor = 0;
pano.renderOrder = 0;

Establish link relationships for panos:

const graph = new PanoGraph();
// graph._links;

graph.link(pano1, pano2, direction);
graph.link(pano2, pano1, direction);

graph.delink(pano2, pano1);

// Get link infos by pano.
// Link() { dirction, from: Pano, to: Pano }
// links: [Link, Link, ...]
const links = graph.getLinks(pano1);

Use Pano Switcher to switch panos by link info and options:

// FadeSwitcher / StretchSwitcher, extend PanoSwitcher
// Or maybe CustomSwitcher by user
const switcher = new FadeSwitcher();

// run switcher
switcher.run(link, options);

// call this per frame to step switcher,deltaTime in seconds
switcher.update(deltaTime);

Use sample:

// When showing a pano
function showPano(pano) {
    const links = graph.getLinks(pano1);

    links.forEach(link => {
        const sprite = new Sprite();
        sprite.position.copy(link.dirction).multiplyScalar(100);

        sprite.addEventListener('click', () => {
            switcher.run(link, { time: 500 }).onUpdate((link, elapsed) => {})
                                             .onComplete((link) => {});
        });
    });
}

How to create CustomSwitcher:

class CustomSwitcher extends PanoSwitcher {

	constructor() {
		super();
	}

    _resetProperties() {
		
	}

	_updateProperties(elapsed) {
        // elapsed is updated by the 'update' function, it from 0 to 1
        // link: { dirction, from: Pano, to: Pano }
        // It is recommended to write code here...
	}

}

t3d-pano's People

Contributors

shawn0326 avatar gailliu avatar

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.