Giter Club home page Giter Club logo

a-frame-component-gltf-pointcloud-transitions's Introduction

A-Frame Component: GLTF based Point Cloud Transitions

Video screen capture

Description / Rationale

This is an A-Frame component, which demonstrates GLTF based point cloud transitions. It was developed based on 3D Models Transitions and Mouse Hovering Effects โ€” ThreeJS article on Medium.com and Austin Mayer's portfolio project.

Instructions

In order to use the component attach "gltf-transitions" to an entity with "gltf-model" component. The component has the following attributes:

  • pointSize: { type: "float", default: 0.2 } - Size of the point cloud points.
  • pointColor: { type: "color", default: "#ffffff" } - Color of the point cloud points.
  • pointOpacity: { type: "float", default: 1.0 } - Opacity of the point cloud points.
  • pointMovement: { type: "string", default: "none" } - If enabled point cloud points move randomly in place. Has the following attributes: "none", "slow", "faster" and "fastest".
  • manualAnimation: { type: "boolean", default: false } - If disabled it will be possible to move point cloud points using mouse scroller. If enabled, it will play point cloud points animation automatically.
  • pauseTime: { type: "float", default: 5 } - the time each point cloud will remain visible before it transitions to another one.

The code below shows the sample implementation of the component:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>A-Frame Component: GLTF Based PointCloud Transitions</title>
  <script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
  <script src="js/gltf-transitions-component.js"></script>
</head>
<body>
  <a-scene>
    <a-entity visible="false" opacity="0" gltf-transitions="pointSize: 0.3; pointColor: #ffffff; pointOpacity: 0.5; pointMovement: slow; manualAnimation: false; pauseTime: 3"
      animation__rotate="property: rotation; dur: 30000; from: 0 0 0; to: 0 360 0; loop: true" id="origin"
      position="0 0 0" rotation="0 0 0" gltf-model="models/shoes.glb" scale="0.1 0.1 0.1"></a-entity>
    <a-entity visible="false" class="target" material="transparent: true; opacity: 0.1;"
      animation__rotate="property: rotation; dur: 30000; from: 0 0 0; to: 0 360 0; loop: true" gltf-model="models/horse.glb"
      scale="0.2 0.2 0.2"></a-entity>
      <a-entity visible="false" class="target" material="transparent: true; opacity: 0.1;"
      animation__rotate="property: rotation; dur: 30000; from: 0 0 0; to: 0 360 0; loop: true" gltf-model="models/stork.glb"
      scale="0.4 0.4 0.4"></a-entity>
      <a-entity visible="false" class="target" material="transparent: true; opacity: 0.1;"
      animation__rotate="property: rotation; dur: 30000; from: 0 0 0; to: 0 360 0; loop: true" gltf-model="models/house.glb"
      scale="1 1 1"></a-entity>
    <a-camera position="-20 20 30"></a-camera>
    <a-sky color="#000000"></a-sky>
  </a-scene>
</body>
</html>

Please note:

  • Gltf entity is not visible by default. If you want to see how 3D model and point cloud is located in 3d space, make it visible.
  • Make sure that there is only one gltf entity with id="origin" and at least one gltf entity with id="target".
  • It is possible to change point cloud positions and rotations. If you decide to do so, please do make sure to make positions and rotatons the same for all gltf entities or just apply to the entity with id='origin'.
  • It is possible, however, to apply different scales for different GLTF entities.
  • Make sure to apply "gltf-transitions" component only to gltf entity with id="origin".

Recommendations

Not all GLTF models will work equally well. It is important to prepare models beforehand. Make sure to do the following:

  • Number of faces of each GLTF file should be close to each other. This is required because generated point cloud points of one GLTF will get transitioned to another one. And if there are less points in the origin GLTF model, then target GLTF model's point cloud will not show completely.
  • To make number of faces almost similar, use Blender's functionality for decimating geometry (when there is a need to reduce number of faces) or subdivide (to increase number of faces).
  • Make sure, if possible, to combine all meshes into single mesh. This will help in generating the point cloud.
  • The more faces are there in a GLTF model, the better it looks visually. However, the more faces also mean slower running experiences.

Tech Stack

The project is powered by AFrame and Three.js. The models used in the example were taken from Poly Pizza (House, shoes) and Three.js library.

Demo

See demo of the component here: Demo

a-frame-component-gltf-pointcloud-transitions's People

Contributors

akbartus avatar

Watchers

 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.